mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
added factorial function
This commit is contained in:
@@ -387,6 +387,21 @@ def primeFactors(minVal=1, maxVal=200):
|
||||
solution = f"{factors}"
|
||||
return problem, solution
|
||||
|
||||
def factorialFunc(maxInput = 6):
|
||||
a = random.randint(0, maxInput)
|
||||
n = a
|
||||
problem = str(a) + "! = "
|
||||
b = 1
|
||||
if a == 1:
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
else:
|
||||
while n > 0:
|
||||
b *= n
|
||||
n = n - 1
|
||||
solution = str(b)
|
||||
return problem, solution
|
||||
|
||||
# || Class Instances
|
||||
|
||||
#Format is:
|
||||
@@ -419,4 +434,5 @@ systemOfEquations = Generator("Solve a System of Equations in R^2", 23, "2x + 5y
|
||||
distance2Point = Generator("Distance between 2 points", 24, "Find the distance between (x1,y1) and (x2,y2)","sqrt(distanceSquared)", distanceTwoPointsFunc)
|
||||
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
|
||||
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)
|
||||
factorial = Generator("Factorial", 28, "a! = ", "b", factorialFunc)
|
||||
Reference in New Issue
Block a user