Home > Back-end > Kill people don't want 3 n 1 suspect
Kill people don't want 3 n 1 suspect
Time:09-26
For any positive integer n, if it is even, then cut it half; If it is odd, then put (3 n + 1) cut in half, so has been cut down repeatedly, finally must be in a particular step by n=1, given any positive integer n is not more than 1000, simply count, how many steps (cut) for n=1?
I want to ask is why loop condition is not the inside of the box? Thank you for passing bosses give directions,
CodePudding user response:
n<=1000 & amp; & N>=0 is conditions, and no limit cycle, cycle conditions as long as it is!=keep You the conditions to join the cause problems, such as cannot be divided exactly by 2, 999 to 999 x3 + 1 this & gt; 1000, withdrew from the cycle,