cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A255140 a(1) = 1, a(n+1) = a(n)/gcd(a(n),n) if this gcd is > 1, else a(n+1) = a(n) + n + 2.

Original entry on oeis.org

1, 4, 2, 7, 13, 20, 10, 19, 29, 40, 4, 17, 31, 46, 23, 40, 5, 24, 4, 25, 5, 28, 14, 39, 13, 40, 20, 49, 7, 38, 19, 52, 13, 48, 24, 61, 99, 138, 69, 23, 65, 108, 18, 63, 109, 156, 78, 127, 177, 228, 114, 38, 19, 74, 37, 94, 47, 106, 53, 114, 19, 82, 41, 106
Offset: 1

Views

Author

M. F. Hasler, Feb 15 2015

Keywords

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.

Examples

			a(2) = a(1) + 3 = 4, a(3) = a(2)/2 = 2, a(4) = a(3) + 5 = 7, a(5) = a(4) + 6 = 13, ...
		

Crossrefs

Programs

  • 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
  • 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 *)
  • 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
    

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.

Extensions

Edited by M. F. Hasler, Jan 11 2020