【 Problem description 】 In the history of Chinese mathematics , There is a widespread “ Han Xin orders soldiers ” The story of : Han Xin is a general under Liu Bang, the emperor of the Han Dynasty , He is brave and good at war , Resourceful , He made outstanding contributions to the Han Dynasty . It is said that Han Xin's math level is also very excellent , When he was ordering troops , To know how many soldiers , While keeping military secrets , Then let the soldiers line up to count off :
Press from 1 to 5 Number off , Write down the number reported by the last soldier as 1; Press again from 1 to 6 Number off , Write down the number reported by the last soldier as 5; Press again from 1 to 7 Number off , Write down the number reported by the last soldier as 4; Finally, press from 1 to 11 Number off , The last soldier reported 10;
Please write a program to calculate how many soldiers Han Xin has at least .
Input format :
No input for this question
Output format :
Output the number of soldiers Han Xin has at least .
The title is as above , I really don't know how to define the scope , The program always reports errors. I don't know why .
flag=0sum=6while(flag!=4): if (sum % 5 == 1): flag=1; else: sum=sum+1 continue if (sum % 6 == 5 and flag == 1): flag = 2; else: sum = sum + 1 continue if (sum % 7 == 4 and flag == 2): flag = 3; else: sum=sum+1 continue if (sum % 11 == 10 and flag == 3): flag = 4; else: sum = sum + 1 continueprint(sum);
The reason is that I accidenta
The sample code for this artic