Problem 123

Prime square remainders

Let *p*_{n} be the *n*th 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}.

**
These problems are part of
Project Euler
and are licensed under
CC BY-NC-SA 2.0 UK
**