fibonacci using recursion
int fib (int n) {
if (n < 2)
return 1;
return fib(n-1) + fib(n-2);
}
fibonacci using recursion
int fib (int n) {
if (n < 2)
return 1;
return fib(n-1) + fib(n-2);
}
fibonacci series using recursion
def fib (n):
if n == 0 or n ==1:
return n
else:
return fib(n-2) + fib(n-1)
#n = int(input("please enter a number "))
n=10
for index,num in enumerate(range(n+1)):
print(f"F{index} :", fib(num))
recursive fibonacci
def fibo2(n):
if n ==1 or n==0:
return 1
else :
n = n+fibo2(n-1)
return n
print(fibo2(n1))
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us