Home > Back-end >  There are n people in a circle, numeral sequence. Personal started to count off from 1 (count off fr
There are n people in a circle, numeral sequence. Personal started to count off from 1 (count off fr

Time:09-27

#include
Void main ()
{
Int n, I, k=0;
While (~ the scanf (" % d ", & amp; N)) {
If (n==0) break;
for(i=1; i<=n; I++) {
K=(k + 3) % I;
}
Printf (" % d \ n ", k + 1);
}
}

Ask what is the principle of this kind of writing, don't understand the logic

CodePudding user response:

I also don't understand, but I suspect that should be a kind of mathematical calculation method

CodePudding user response:

This is the classic Joseph ring

CodePudding user response:

https://blog.csdn.net/qq_21201267/article/details/104442971
Joseph ring problem, please refer to my blog
https://blog.csdn.net/qq_21201267/article/details/88563448
  • Related