Input - 8, Output - 21
Write an algorithm to make a list like 1,1,2,3,5,8,13,21 so when input 8 is entered it should give output 21.(NA)
def isLucky(n):
if isLucky.C > n:
return 1
if n % isLucky.C == 0:
return 0
pos = n - (n/isLucky.C)
isLucky.C = isLucky.C + 1
return isLucky(pos)
isLucky.C = 2
for x in range(0,8):
x = int(input(""))
if isLucky(x):
print (x,"is a Lucky number")
else:
print (x,"is not a Lucky number")
Comments
Leave a comment