OFFSET
1,2
LINKS
Robert Israel, Mathematics StackExchange, When does x^3-x^2-2x+1 split mod p.
Wikipedia, Pisano period.
FORMULA
From Robert Israel, Jun 14 2017: (Start)
If m and n are coprime, a(m*n) = lcm(a(m),a(n)).
If p is a prime such that the polynomial x^3-x^2-2*x+1 splits into distinct factors mod p, then a(p) divides p-1. These primes are A045472. (End)
MAPLE
f:= proc(n) option remember; local F, t, k, a;
F:= ifactors(n)[2];
if nops(F) > 1 then
return(ilcm(seq(procname(t[1]^t[2]), t=F)))
fi;
a:= [0, 0, 1];
for k from 1 do
a:= [a[2], a[3], 2*a[3]+a[2]-a[1] mod n];
if a = [0, 0, 1] then return k fi;
od:
end proc:
f(1):= 1:
map(f, [$1..100]); # Robert Israel, Jun 14 2017
MATHEMATICA
Table[FindTransientRepeat[
Mod[LinearRecurrence[{2, 1, -1}, {0, 0, 1}, 100000], n], 2] //
Last // Length, {n, 1, 20}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Patrick D McLean, Apr 02 2017
EXTENSIONS
More terms from Robert Israel, Jun 14 2017
STATUS
proposed