A104217 Period of Perrin (0,2,3,2,5,5,..., A001608) sequence mod n.
1, 7, 13, 14, 24, 91, 48, 28, 39, 168, 120, 182, 183, 336, 312, 56, 288, 273, 180, 168, 624, 840, 22, 364, 120, 1281, 117, 336, 871, 2184, 993, 112, 1560, 2016, 48, 546, 1368, 1260, 2379, 168, 1723, 4368, 231, 840, 312, 154, 2257, 728, 336, 840, 3744, 2562
Offset: 1
Keywords
Links
- T. D. Noe, Table of n, a(n) for n=1..1000
Programs
-
Mathematica
Table[a={0,2,3}; a=a0=Mod[a, n]; k=0; While[k++; s=a[[2]]+a[[1]]; a=RotateLeft[a]; a[[ -1]]=Mod[s,n]; a!=a0]; k, {n,100}] (* T. D. Noe, Oct 10 2006 *)
-
Python
from math import lcm from functools import lru_cache from sympy import factorint @lru_cache(maxsize=None) def A104217(n): if n < 4: return (1,7,13)[n-1] f = factorint(n).items() if len(f) > 1: return lcm(*(A104217(a**b) for a,b in f)) else: k,x = 1, (0,2,3) while x != (3,0,2): k += 1 x = (x[1], x[2], (x[0]+x[1]) % n) return k # Chai Wah Wu, Apr 25 2025
Extensions
More terms from T. D. Noe, Oct 10 2006
Comments