· Einstein's ladder problem : There is a ladder , Each step 2 rank , Last remaining 1 rank ; Each step 3 rank , Last remaining 2 rank ; Each step 5 rank , Last remaining 4 rank ; Each step 6 rank , Last remaining 5 rank ; Only every step 7 Step time , Just to the top of the stairs . Ask how many steps there are at least ?
Required while Loop statement
(x % 2 == 1) and (x % 3 == 2) and (x % 5 == 4) and (x % 6 == 5) and (x % 7 ==0)
x = 1
while x < 1000: # set up 1000 The minimum number of steps can be input internally
if (x % 2 == 1) and (x % 3 == 2) and (x % 5 == 4) and (x % 6 == 5) and (x % 7 ==0):
print(' At least ',x,' Step ladder ')
x += 1
break # Out of the loop
else:
x += 1
print(" The loop ends ")
There are different views that can be discussed in the message below (^ - ^)