Solution:
Number the vertices 0,1,…,n−1 clockwise starting at the vertex Zagi is on. After his i-th jump Zagi will be at a vertex numbered 1+2+⋯+i=2i(i+1)(modn). We need to prove that if for all k∈{0,1,2,…,⌈2n⌉} the fractions 2k(k+1) achieve different values modulo n then they achieve different values modulo n even for all k∈{0,1,2,…,n−1}. We will in fact prove two following claims:
- for numbers of the form n=2r, with r≥2, all k∈{0,1,2,…,n−1} the fractions 2k(k+1) achieve different values mod n;
- for numbers of the form n=2r⋅l, with r≥0 and l≥3 odd, we have that there exist distinct a,b∈{0,1,2,…,⌈2n⌉} such that 2a(a+1)≡2b(b+1)(modn).
Let us firstly observe n of the form 2r, with r≥2. Let us assume that there are 1≤b<a≤n−1 such that 2a(a+1)≡2b(b+1)(mod2r). Equivalently, 2r+1∣(a−b)(a+b+1). Factors on the right hand side have different parity, thus we have either 2r+1∣a−b or 2r+1∣a+b+1. In the first case we have that a−b≤n−1<2n. In the second case we have a+b+1≤(n−1)+(n−2)+1=2n−2<2n. Hence, in both cases we obtain contradiction, and we can conclude that there indeed do not exist such a and b.
Let us now observe n of the form 2r⋅l, with r≥0,l≥3 odd. Set M=max{2r+1,l} and m=min{2r+1,l}. We claim that the pair (a,b)=(2M+m−1,2M−m−1) satisfies the desired conditions. Indeed:
- Since 2r+1 is even and l is odd, both M+m−1 and M−m−1 are even and thus a,b are integers.
- We have: 2a(a+1)−2b(b+1)=21(a−b)(a+b+1)=21m⋅M=2rl=n.
- Since M>m>0, we have 0≤b<a.
It remains to argue that a≤⌈2n⌉. Since r≥0 and l≥3 we conclude that both m,M are greater or equal to min{2r+1,l}≥2. From mM=2n, they are both less or equal to n. So we have inequality (m−n)(m−2)≤0, which implies m+M=m+m2n≤2+n. Hence a=2M+m−1≤2n+1≤⌈2n⌉ as desired.