A179738 a(n) = length of (eventual) period of the sequence defined by s(0) = 1, s(n+1) = odd_part(2n-1 + (s(n) if n odd else s(n)*3)), where odd_part = A000265.
1, 2, 4, 1, 4, 8, 2, 4, 8, 4, 2, 2, 1, 4, 12, 4, 4, 26, 2, 12, 6, 2, 4, 4, 4, 16, 4, 8, 10, 6, 4, 8, 4, 2, 6, 8, 12, 12, 28, 1, 22, 16, 2, 16, 12, 12, 16, 6, 4, 40, 24, 4, 32, 6, 26, 16, 6, 8, 4, 8, 12, 2, 36, 6, 46, 12, 2, 36, 60, 6, 16, 8, 4, 18, 20, 4, 60, 36
Offset: 2
Keywords
Examples
For n = 4, 2*n-1 = 7, we get: 7 <+> 1 = 1, 7 <+> 3*1 = 5, 7 <+> 5 = 3, 7 <+> 3*3 = 1, and from here on it starts over with 7 <+> 1 = 1, etc., so the period is [1, 5, 3, 1], of length 4, whence a(4) = 4. For n = 6, 2*n-1 = 11, we get: 11 <+> 1 = 3, 11 <+> 3*3 = 5, 11 <+> 5 = 1, 11 <+> 3*1 = 7, 11 <+> 7 = 9, 11 <+> 3*9 = 19, 11 <+> 19 = 15, 11 <+> 3*15 = 7, 11 <+> 7 = 9, ... Thus we have an eventually periodic sequence with the smallest period 4 (with elements 7, 9, 19, 15). Thus a(6) = 4.
Links
- Jason Yuen, Table of n, a(n) for n = 2..10000 (terms 2..1000 from M. F. Hasler)
Programs
-
PARI
apply( {A179738(n, y=1, T(y, x=2*n-1)=(x+y)>>valuation(x+y,2))=my(s=[], P); until(, s=concat(s, y=T(3^(#s%2)*y)); for(L=1, #s\3, P=[vecextract(s,Str(-L-t,"..-",1+t)) | t<-[0,L,2*L]]; P[1]==P[2] && P[1]==P[3] && return(#P[1])))}, [2..90])
-
Python
def A179738(n): s = [1]; x = 2*n-1; odd = lambda z: all(z&1 or(z:=z>>1)for _ in range(z))and z while not(p := next((p for p in range(1, len(s)//3+1) if s[-p:]==s[-2*p:-p]==s[-3*p:-2*p]), 0)): s.append(odd(x+3**(len(s)&1)*s[-1])) return p print([A179738(n)for n in range(2,99)]) # M. F. Hasler, Feb 16 2025
Extensions
Name edited and corrections proposed by Jason Yuen, Feb 09 2025
Edited, a(4) and a(18) corrected, and extended by M. F. Hasler, Feb 15 2025
Comments