I was trying to code the problem Candies, yesterday and my logic was
In order to find a solution to
x + 2x + 4x ... = n
x(2^k — 1) = n
x = n / (2^k — 1 )
So I go through the factors of n in square root n time and check if they're of the same form as the denominator.
But apparently it times out, can someone shed some light on this?