mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Fixed Multiplication parameters
This commit is contained in:
committed by
GitHub
parent
8e2df67c1e
commit
e121dd8b1e
@@ -36,17 +36,9 @@ def subtractionFunc(maxMinuend = 99, maxDiff = 99):
|
|||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
def multiplicationFunc(maxRes = 99, maxMulti = 99):
|
def multiplicationFunc(maxRes = 99, maxMulti = 99):
|
||||||
c = random.randint(0, maxMulti) # Generate the solution to the problem
|
a = random.randint(0, maxMulti)
|
||||||
i = int(1)
|
b = random.randint(0, min(int(maxMulti/a), maxRes))
|
||||||
j = 0 #Indices for the loop
|
c = a*b
|
||||||
d = [] #Array to store the factors
|
|
||||||
while(i<=c): #Factors are less than or equal to the number
|
|
||||||
if(c%i == 0): #If the remainder is 0, the number is a factor
|
|
||||||
d[j] = i #Store the factor
|
|
||||||
j += 1 #Move to the next index
|
|
||||||
i += 1 #Next number
|
|
||||||
a = random.randint(0, c) #Generate a multiplicant
|
|
||||||
b = c/a #Find the other multiplicant
|
|
||||||
problem = str(a) + "*" + str(b) + "="
|
problem = str(a) + "*" + str(b) + "="
|
||||||
solution = str(c)
|
solution = str(c)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|||||||
Reference in New Issue
Block a user