Project Euler Problem 711

Oscar and Eric play the following game.

Project Euler Problem 711

Solution

Answer: 541510990

Using the derived recurrence structure for the Eric-winning positions (which reduces the problem to closed-form geometric sums and a simple linear recurrence), the computation gives:

$$S(12{,}345{,}678)\equiv 541510990 \pmod{1,000,000,007}.$$

The recurrence and verification conditions $S(4)=46$, $S(12)=54532$, and $S(1234)\equiv690421393\pmod{1,000,000,007}$ are consistent with the implementation shown in the referenced solution.

Answer: 541510990