← RoseCode

ROSECODE 240

Generalized Pisano Period 2

Min_25 · Math ·

Let Fk(n) be a linear recurrence sequence such that Fk(n)=1 (1nk),Fk(n)=i=1kFk(ni) (n>k).

For example, F2(1)=1, F2(2)=1 and F2(3)=2

Let P(k,m) be the (minimum) period of Fk(n) modulo m.

You are given that P(2,10)=60 and P(2,109)=1 500 000 000.

Find P(50,109).

Note: The answer is a 29 digit number.

[My timing: 42 sec (PyPy)]