Answer to Question #264543 in Python for swsq

Question #264543
  1. To find the lucky number.

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)




1
Expert's answer
2021-11-12T17:37:01-0500
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")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS