ncinthala n=int(input(‘enter the nth number ‘)); temp=0; temp1=1; sum=0; arr=[]; arr.append(temp); arr.append(temp1); for i in range(1,n-1): sum=temp+temp1; temp=temp1; temp1=sum; arr.append(sum); print(arr[n-1]); Log in to Reply
sufiyashaik781 def fib(N): if N==0: return [] elif N==1: return [0] elif N==2: return [0,1] else: arr=[0,1] for i in range(2,N): n=arr[i-1]+arr[i-2] arr.append(n) return n N=int(input()) print(fib(N)) Log in to Reply
n=int(input(‘enter the nth number ‘));
temp=0;
temp1=1;
sum=0;
arr=[];
arr.append(temp);
arr.append(temp1);
for i in range(1,n-1):
sum=temp+temp1;
temp=temp1;
temp1=sum;
arr.append(sum);
print(arr[n-1]);
def fib(N):
if N==0:
return []
elif N==1:
return [0]
elif N==2:
return [0,1]
else:
arr=[0,1]
for i in range(2,N):
n=arr[i-1]+arr[i-2]
arr.append(n)
return n
N=int(input())
print(fib(N))
import math
n=5
print(math.factorial(n))