Project Euler Problem 123
Brute force, with minor optimizations, seems to have worked here. Using cython
shaved a few seconds off the runtime, but not enough to be hugely noticable.
Additionally, I narrowed the search range by figuring that the remainder has to
take place after the prime is 10**5.
Revision 1:
Reduce search space further by remembering that it's unlikely for n % (10**10 + epsilon) >= 10**10
Problem:
Let p[n] be the nth prime: 2, 3, 5, 7, 11, ..., and let r be the remainder when
(p[n]−1)**n + (p[n]+1)**n is divided by p[n]**2.
For example, when n = 3, p[3] = 5, and 4**3 + 6**3 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10**9 is 7037.
Find the least value of n for which the remainder first exceeds 10**10.