mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Adding a new math function commonFactors
This commit is contained in:
@@ -387,6 +387,26 @@ def primeFactors(minVal=1, maxVal=200):
|
|||||||
solution = f"{factors}"
|
solution = f"{factors}"
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
def commonFactors(maxVal=100):
|
||||||
|
a = random.randint(1, maxVal)
|
||||||
|
b = random.randint(1, maxVal)
|
||||||
|
x, y = a, b
|
||||||
|
c = a * b
|
||||||
|
if (x < y):
|
||||||
|
min = x
|
||||||
|
else:
|
||||||
|
min = y
|
||||||
|
count = 0
|
||||||
|
arr = []
|
||||||
|
for i in range(1, min + 1):
|
||||||
|
if (x % i == 0):
|
||||||
|
if (y % i == 0):
|
||||||
|
count = count + 1
|
||||||
|
arr.append(i)
|
||||||
|
problem = f"Common Factors of {a} and {b} = "
|
||||||
|
solution = arr
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
#Format is:
|
#Format is:
|
||||||
@@ -420,3 +440,4 @@ distance2Point = Generator("Distance between 2 points", 24, "Find the distance b
|
|||||||
pythagoreanTheorem = Generator("Pythagorean Theorem", 25, "The hypotenuse of a right triangle given the other two lengths a and b = ", "hypotenuse", pythagoreanTheoremFunc)
|
pythagoreanTheorem = Generator("Pythagorean Theorem", 25, "The hypotenuse of a right triangle given the other two lengths a and b = ", "hypotenuse", pythagoreanTheoremFunc)
|
||||||
linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12", "x=-20 & y=12", linearEquationsFunc) #This has multiple variables whereas #23 has only x and y
|
linearEquations = Generator("Linear Equations", 26, "2x+5y=20 & 3x+6y=12", "x=-20 & y=12", linearEquationsFunc) #This has multiple variables whereas #23 has only x and y
|
||||||
primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =", "[b, c, d, ...]", primeFactors)
|
primeFactors = Generator("Prime Factorisation", 27, "Prime Factors of a =", "[b, c, d, ...]", primeFactors)
|
||||||
|
commonFactors = Generator("Common Factors", 28, "Common Factors of {a} and {b} = ","[c, d, ...]",commonFactors)
|
||||||
Reference in New Issue
Block a user