← Complete problem index

PROJECT EULER · #0999

Alternating Recurrence

Statement only · UnsolvedOriginal problem ↗

There is a unique sequence of integers an such that

  • a1=a2=a3=1, a4=2;
  • an2=an+2an2+uan+1an1, where u=1 if n is even and u=2 if n is odd.

For example, a13=23321 and a1003231906014(mod1234567891).

For n=1018+3, find anmod1234567891.

Write-up coming later

The complete problem is available here. An approach, code, and answer will be added later.