def Lucas(n):
a=[]
i=0
while i!=n+1:
if i==0:
a.append(2)
elif i==1:
a.append(1)
else:
a.append(a[i-1]+a[i-2])
i+=1
return a[n]
print Lucas(input())
Read more about Lucas Number..
a=[]
i=0
while i!=n+1:
if i==0:
a.append(2)
elif i==1:
a.append(1)
else:
a.append(a[i-1]+a[i-2])
i+=1
return a[n]
print Lucas(input())
Read more about Lucas Number..
No comments:
Post a Comment