This problem is solved by simple emulation. After 2n jumps flea returns to initial position, because 1 + 2 + 3 + ... + 2n = n(2n + 1) is divisible by n. Moreover, after that, jumps would be the same as in the beginning, because 2n is divisible by n. So it is just enough to emulate first 2n jumps.
In fact one may see that it is enough to emulate first n jumps and moreover answer is "YES" exactly when n is power of two. Last gives alternative solution. For example: printf("%s", n&(n-1) : "NO" ? "YES");