We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have runtime error with O(2**n) solution. Is it the same for you?
Here's my Python code:
def fibonacciModified(t1, t2, n):
# Write your code here
def getfibonacci(n):
if n == 1:
return t1
elif n == 2:
return t2
else:
return getfibonacci(n-2) + getfibonacci(n-1)**2
return getfibonacci(n)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci Modified
You are viewing a single comment's thread. Return to all comments →
I have runtime error with O(2**n) solution. Is it the same for you? Here's my Python code: def fibonacciModified(t1, t2, n): # Write your code here def getfibonacci(n): if n == 1: return t1 elif n == 2: return t2 else: return getfibonacci(n-2) + getfibonacci(n-1)**2 return getfibonacci(n)