mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
Updated Basic Algebra Function
fixed the denominator issue
This commit is contained in:
@@ -121,6 +121,26 @@ def lcmFunc(maxVal=20):
|
|||||||
solution = str(d)
|
solution = str(d)
|
||||||
return problem, solution
|
return problem, solution
|
||||||
|
|
||||||
|
def basicAlgebraFunc(maxVariable = 10):
|
||||||
|
a = random.randint(1, maxVariable)
|
||||||
|
b = random.randint(1, maxVariable)
|
||||||
|
c = random.randint(b, maxVariable)
|
||||||
|
# calculate gcd
|
||||||
|
def calculate_gcd(x, y):
|
||||||
|
while(y):
|
||||||
|
x, y = y, x % y
|
||||||
|
return x
|
||||||
|
i = calculate_gcd((c - b), a)
|
||||||
|
x = f"{(c - b)//i}/{a//i}"
|
||||||
|
if (c - b == 0):
|
||||||
|
x = "0"
|
||||||
|
elif a == 1 or a == i :
|
||||||
|
x = f"{c - b}"
|
||||||
|
problem = f"{a}x + {b} = {c}"
|
||||||
|
solution = x
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
#Format is:
|
#Format is:
|
||||||
@@ -136,3 +156,4 @@ powerRuleDifferentiation = Generator("Power_Rule_Differentiation", 9, "nx^m=", "
|
|||||||
square = Generator("Square", 10,"a^2", "b", squareFunc)
|
square = Generator("Square", 10,"a^2", "b", squareFunc)
|
||||||
lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc)
|
lcm = Generator("Lcm_generator", 11, "LCM of a and b = ", "c", lcmFunc)
|
||||||
gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc)
|
gcd = Generator("Gcd_generator", 12, "GCD of a and b = ", "c", gcdFunc)
|
||||||
|
basicAlgebra = Generator("Basic_Algebra", 13, "ax + b = c", "d", basicAlgebraFunc)
|
||||||
|
|||||||
Reference in New Issue
Block a user