Files
mathgenerator/mathgenerator/funcs/nthFibonacciNumberFunc.py
2020-10-18 23:48:13 -04:00

11 lines
332 B
Python

from .__init__ import *
def nthFibonacciNumberFunc(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