Divide out every factor of 2 and look at what remains. Since n reaches 10^14, use 64-bit integers.
n
10^14
New here? Create an account