OFFSET
2,2
COMMENTS
The multiplicative order of term n modulo n is given by sequence A001176.
Let M = [{1, 1}, {1, 0}], I = [{1, 0}, {0, 1}] is the 2 X 2 identity matrix, then A001177(n) is the smallest k > 0 such that M^k == r*I (mod n) for some r such that 0 <= r < n, and a(n) gives the value r. - Jianing Song, Jul 04 2019
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 2..10000
FORMULA
a(n) = F(G(n)-1) mod n where G(n) is sequence A001177 and F(m) is the m-th Fibonacci number. In particular, if n is a Fibonacci number, the n-th term is the previous Fibonacci number.
From Jianing Song, Jul 04 2019:
Also a(n) = F(G(n)+1) mod n.
a(2^e) = 1 if e = 1, 2, 2^(e-1) + 1 if e >= 3; a(p^e) = a(p)^(p^(e-1)) mod p^e for odd primes p.
MAPLE
a:= proc(n) local f, g; f, g:= 1, 0;
while f<>0 do f, g:= irem(f+g, n), f od; g
end:
seq(a(n), n=2..100); # Alois P. Heinz, Sep 24 2012
MATHEMATICA
Table[k = 1; While[Mod[Fibonacci[k], n] > 0, k++]; Mod[Fibonacci[k - 1], n], {n, 2, 100}] (* T. D. Noe, Sep 24 2012 *)
PROG
(PARI) a(n)=my(a=0, b=1); for(k=1, n^2, [a, b]=[b, (a+b)%n]; if(!b, return(a))) \\ Charles R Greathouse IV, Sep 24 2012
CROSSREFS
KEYWORD
nonn
AUTHOR
David Spies, Sep 24 2012
EXTENSIONS
a(14)-a(70) from Charles R Greathouse IV, Sep 24 2012
STATUS
approved