
Alexander B. answered 05/18/18
Tutor
5
(7)
Advanced Math and Science Tutoring and Test Prep online (SAT, ACT)
First, let's notice that the position p of rightmost "1" in the sequence should satisfy the equation:
p2 +p < 2*n
based on the observation that the sum of the elements to the left of that rightmost "1" is
s = 0.5(p+1)*p
corresponding to the series:
1+2+3+4 +... +p
Position p must be a whole number calculated as the root of quadratic equation p2 +p -2n =0 rounded down (notice the Int operator):
pround = Int (-p/2 + √(p2/4 +2n))
The answer will be found as a difference: n - 0.5pround(pround +1)
In this particular case of n=5060, pround = 100, thus an = 5060 - 0.5*100*101 = 10
an = 10 (the answer)