Don't dare to die Time Limit: 1000 ms memory limit: 65536 k any questions? Click Here ^_^ Description
When it comes to "death squad", don't introduce the movie to me, because there is such a program design question in the data structure. The original question is as follows:
There are m death squads who want to blow up an enemy's bunker. No one wants to go. The length of the platoon decides which fighters to execute the task by means of the number of rounds. If the previous warrior fails to complete the task, send another warrior. Now we have a code for each warrior. Everyone is sitting in a circle and counting it from a warrior. When the number is 5, the corresponding warrior executes the task, this warrior will not participate in the next round of counting. If the warrior does not complete the task, count from the next one. When the number of soldiers reaches 5th, the warrior proceeds to execute the task. And so on until the task is completed.
This question was originally called "death squad ". "No one wants to go." I think this problem can only be called "No death ". Today, we are about to solve this problem. Let's assume that the length is 1. According to the above introduction, the number of soldiers starting from 1 and counting to 5 will execute the task. What is the length of the platoon to execute the task?
Input
The input includes multi-test data. Each row has an integer m (0 <= m <= 10000) (number of death squads). If M = 0, the input ends without processing.
Output
Output an integer N, indicating that the length is the nth to execute the task.
Sample Input
9
6
223
0
Sample output
2
6
132
Application of Joseph's Problem