mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 14:35:23 +01:00
@@ -4,7 +4,6 @@ import fractions
|
|||||||
|
|
||||||
genList = []
|
genList = []
|
||||||
|
|
||||||
|
|
||||||
# || Generator class
|
# || Generator class
|
||||||
class Generator:
|
class Generator:
|
||||||
def __init__(self, title, id, generalProb, generalSol, func):
|
def __init__(self, title, id, generalProb, generalSol, func):
|
||||||
@@ -954,6 +953,15 @@ def volumeSphereFunc(maxRadius=100):
|
|||||||
ans = (4 * math.pi / 3) * r * r * r
|
ans = (4 * math.pi / 3) * r * r * r
|
||||||
solution = f"{ans} m^3"
|
solution = f"{ans} m^3"
|
||||||
return problem,solution
|
return problem,solution
|
||||||
|
|
||||||
|
def nthFibonacciNumber(maxN = 100):
|
||||||
|
golden_ratio = (1 + math.sqrt(5))/2
|
||||||
|
n = random.randint(1,maxN)
|
||||||
|
problem = f"What is the {n}th Fibonacci number?"
|
||||||
|
ans = round((math.pow(golden_ratio,n) - math.pow(-golden_ratio,-n))/(math.sqrt(5)))
|
||||||
|
solution = f"{ans}"
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
|
|
||||||
@@ -1075,3 +1083,4 @@ surfaceAreaSphereGen = Generator(
|
|||||||
"Surface Area of Sphere", 59, "Surface area of sphere with radius = a units is", "d units^2", surfaceAreaSphere)
|
"Surface Area of Sphere", 59, "Surface area of sphere with radius = a units is", "d units^2", surfaceAreaSphere)
|
||||||
volumeSphere = Generator("Volume of Sphere", 60,
|
volumeSphere = Generator("Volume of Sphere", 60,
|
||||||
"Volume of sphere with radius r m = ", "(4*pi/3)*r*r*r", volumeSphereFunc)
|
"Volume of sphere with radius r m = ", "(4*pi/3)*r*r*r", volumeSphereFunc)
|
||||||
|
nthFibonacciNumberGen = Generator("nth Fibonacci number", 61, "What is the nth Fibonacci number", "Fn", nthFibonacciNumber)
|
||||||
|
|||||||
Reference in New Issue
Block a user