login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A255051
a(1)=1, a(n+1) = a(n)/gcd(a(n),n) if this GCD is > 1, else a(n+1) = a(n) + n + 1.
6
1, 3, 6, 2, 1, 7, 14, 2, 1, 11, 22, 2, 1, 15, 30, 2, 1, 19, 38, 2, 1, 23, 46, 2, 1, 27, 54, 2, 1, 31, 62, 2, 1, 35, 70, 2, 1, 39, 78, 2, 1, 43, 86, 2, 1, 47, 94, 2, 1, 51, 102, 2, 1, 55, 110, 2, 1, 59, 118, 2, 1, 63, 126, 2, 1, 67, 134, 2, 1, 71, 142, 2, 1
OFFSET
1,2
COMMENTS
A somehow "trivial" variant of A133058 and A255140, both of which have very similar definitions, but enter 4-periodic loops only at later indices.
There could be two motivated values for an initial term: either a(0)=0 which would yield a(1)=1 and the following values via the recursion formula, or a(0)=2 according to the general formula for a(4k).
FORMULA
a(4k+1) = 1, a(4k+2) = 4k+3, a(4k+3) = 2*a(4k+2) = 8k+6, a(4k) = 2.
G.f.: x*(1 + 3*x + 6*x^2 + 2*x^3 - x^4 + x^5 + 2*x^6 - 2*x^7)/((1 - x)^2*(1 + x)^2*(1 + x^2)^2). - Bruno Berselli, Feb 16 2015
a(n) = ( 2*(3 + (-1)^n) - (2 - 3*n + n*(-1)^n)*(1 - (-1)^((n-1)*n/2)) )/4. - Bruno Berselli, Feb 16 2015
EXAMPLE
a(2) = a(1)+2 = 3, a(3) = a(2)+3 = 6, a(4) = a(3)/3 = 2, a(5) = a(4)/2 = 1;
a(6) = a(5)+6 = 7, a(7) = a(6)+7 = 14, a(8) = a(7)/7 = 2, a(9) = a(8)/2 = 1; ...
MATHEMATICA
Table[(2 (3 + (-1)^n) - (2 - 3 n + n (-1)^n) (1 - (-1)^((n - 1) n/2)))/4, {n, 1, 80}] (* Bruno Berselli, Feb 16 2015 *)
nxt[{n_, a_}]:={n+1, If[GCD[a, n]>1, a/GCD[a, n], a+n+1]}; Transpose[ NestList[ nxt, {1, 1}, 80]][[2]] (* or *) LinearRecurrence[{0, 0, 0, 2, 0, 0, 0, -1}, {1, 3, 6, 2, 1, 7, 14, 2}, 80] (* Harvey P. Dale, Oct 13 2015 *)
PROG
(PARI) (A255051_upto(N)=vector(N, n, if(gcd(N, n-1)>1, N\=gcd(N, n-1), N+=n)))(99) \\ simplified by M. F. Hasler, Jan 11 2020
(PARI) A255051(n)=if(n%4>1, if(bittest(n, 0), n*2, n+1), 2-bittest(n, 0)) \\ M. F. Hasler, Feb 18 2015
(Magma) &cat [[1, 4*n+3, 8*n+6, 2]: n in [0..20]]; // Bruno Berselli, Feb 16 2015
CROSSREFS
Sequence in context: A238555 A176034 A367729 * A145896 A159963 A120907
KEYWORD
nonn,easy
AUTHOR
M. F. Hasler, Feb 15 2015
STATUS
approved