OFFSET
1,2
LINKS
Joerg Arndt, Table of n, a(n) for n = 1..1000
H. T. Engstrom, On sequences defined by linear recurrence relations, Trans. Am. Math. Soc. 33 (1) (1931) 210-218.
K. Kirthi, Narayana Sequences for Cryptographic Applications, arXiv preprint arXiv:1509.05745 [math.NT], 2015.
M. B. Nathanson, Linear recurrences and uniform distribution, Proc. Amer. Math. Soc. 48 (1975), 289-291.
D. D. Wall, Fibonacci series modulo m, Amer. Math. Monthly, 67 (1960), 525-532.
FORMULA
Let the prime factorization of n be p1^e1*...*pk^ek. Then a(n) = lcm(a(p1^e1), ..., a(pk^ek)) [Engstrom]. - N. J. A. Sloane, Feb 18 2017
MATHEMATICA
minlen = 100; maxlen = 2*10^4;
per[lst_] := FindTransientRepeat[lst, 2] // Last // Length;
a[n_] := Module[{p0=0, len=minlen}, While[p0 = Mod[LinearRecurrence[{1, 0, 1}, {1, 1, 1}, len], n] // per; p0<=1 && len<=maxlen, len = 2 len]; p0];
Table[an = a[n]; Print["a(", n, ") = ", an]; an, {n, 1, 100}] (* Jean-François Alcover, Jul 21 2018 *)
PROG
(PARI)
per(n, S, R) = { \\ S[]: leading terms, R[]: recurrence
if ( n==1, return( 1 ) );
my ( r = #R );
if ( r != #S , error("Mismatch in length of S[] and R[]") );
S = vector(#S, j, Mod(S[j], n) );
R = vector(#S, j, Mod(R[j], n) );
my( T = S );
my( j = 0 );
until ( 0, \\ forever
j += 1;
my( t = sum(i=1, r, R[i] * T[r+1-i] ) ); \\ next term
for (k=1, r-1, T[k] = T[k+1] );
T[r] = t;
if ( T == S , return(j) );
);
}
\\vector(66, n, per(n, [0, 1], [1, 1]) ) \\ A001175
\\vector(66, n, per(prime(n), [0, 1], [1, 1]) ) \\ A060305
vector(66, n, per(n, [0, 0, 1], [1, 0, 1]) ) \\ A271953
\\vector(66, n, per(prime(n), [0, 0, 1], [1, 0, 1]) ) \\ A271901
\\vector(66, n, per(n, [0, 0, 1], [0, 1, 1]) ) \\ A104217
/* Joerg Arndt, Apr 17 2016 */
CROSSREFS
KEYWORD
nonn
AUTHOR
Joerg Arndt, Apr 17 2016
STATUS
approved