Made GOLDEN_RATIO local

This commit is contained in:
Luke Weiler
2020-10-18 22:38:28 -04:00
committed by GitHub
parent e1c50c5fd6
commit 127b73abe8

View File

@@ -3,7 +3,6 @@ import math
import fractions import fractions
genList = [] genList = []
GOLDEN_RATIO = (1 + math.sqrt(5))/2
# || Generator class # || Generator class
class Generator: class Generator:
@@ -922,9 +921,10 @@ def volumeSphereFunc(maxRadius = 100):
return problem,solution return problem,solution
def nthFibonacciNumber(maxN = 100): def nthFibonacciNumber(maxN = 100):
golden_ratio = (1 + math.sqrt(5))/2
n = random.randint(1,maxN) n = random.randint(1,maxN)
problem = f"What is the {n}th Fibonacci number?" problem = f"What is the {n}th Fibonacci number?"
ans = round((math.pow(GOLDEN_RATIO,n) - math.pow(-GOLDEN_RATIO,-n))/(math.sqrt(5))) ans = round((math.pow(golden_ratio,n) - math.pow(-golden_ratio,-n))/(math.sqrt(5)))
solution = f"{ans}" solution = f"{ans}"
return problem, solution return problem, solution