MathLabs

Problem 4

During a break, n children sit in a circle. A teacher chooses one child and gives a candy, skips the next child and gives one to the following child, then skips 2 children, then 3, and so on. For which n will every child eventually receive at least one candy?
Step 1 of 4: Encode the visited positions
f(x)=x(x+1)2(modn).f(x)=\frac{x(x+1)}2\pmod n.
Detailed analysis

After skipping 0,1,2,... children, the successive positions differ by 1,2,3,... modulo n. Thus, up to a shift of the starting label, the position after x steps is the triangular number f(x).