Answer: n=4021.
Using the formula for sum of a geometric progression, we have:
−20+21−22+23−24+⋯+(−2)n=(−2)n+1−1⋅((−2)n+1−1)
The right side is:
40+41+42+⋯+42010=4−142011−1=342011−1
So, equating both sides:
(−2)n+1−1⋅((−2)n+1−1)=342011−1
Multiply both sides by (−2)n+1:
−((−2)n+1−1)=342011−1⋅(−2)n+1
But from the context, the solution proceeds:
(−2)n+1=42011
It follows that n must be odd. Then n=2m+1⇒(−2)2m+2=42011⇒4m+1=42011 implying m=2010 and n=4021.