OFFSET
1,2
COMMENTS
A variant of A133058, less trivial than A255051: The sequence looks irregular up to index n = 82, where it enters a 4-periodic pattern (1, x, 2x, x), cf. formula. Sequence A255051 starts right from the beginning with the pattern (1, x, 2x, 2), whereas sequence A133058 enters such a pattern only at index n = 641.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..1000
FORMULA
For k > 20, a(4k) = 8k + 2 = 2*a(4k +- 1), a(4k - 2) = 1; equivalently:
a(n) = 2n + 2, n, 1 or n+2 when n = 4k+r > 81 with r = 0, 1, 2 or 3, respectively.
EXAMPLE
a(2) = a(1) + 3 = 4, a(3) = a(2)/2 = 2, a(4) = a(3) + 5 = 7, a(5) = a(4) + 6 = 13, ...
MATHEMATICA
nxt[{n_, a_}]:=Module[{g=GCD[a, n]}, {n+1, If[g>1, a/g, a+n+2]}]; NestList[nxt, {1, 1}, 70][[All, 2]] (* Harvey P. Dale, Oct 12 2019 *)
PROG
(PARI) A255140_vec(N)=vector(N, n, if(gcd(N, n-1)>1||n==1, N/=gcd(N, n-1), N+=n+1)) \\ Original code simplified by M. F. Hasler, Jan 11 2020
(PARI) A255140(n)=if(n < 82, A255140_upto(n)[n], [2*n+2, n, 1, n+2][n%4+1]) \\ M. F. Hasler, Jan 17 2020
(Magma) a:=[1]; for n in [2..65] do if Gcd(a[n-1], n-1) gt 1 then Append(~a, a[n-1] div Gcd(a[n-1], n-1)); else Append(~a, a[n-1] +n+1); end if; end for; a; // Marius A. Burtea, Jan 11 2020
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
M. F. Hasler, Feb 15 2015
EXTENSIONS
Edited by M. F. Hasler, Jan 11 2020
STATUS
approved