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.

A277618 Lexicographically earliest nonnegative sequence such that |a(n+1)-a(n)| is a prime number, and no number occurs twice; a(0) = 0.

Original entry on oeis.org

0, 2, 4, 1, 3, 5, 7, 9, 6, 8, 10, 12, 14, 11, 13, 15, 17, 19, 16, 18, 20, 22, 24, 21, 23, 25, 27, 29, 26, 28, 30, 32, 34, 31, 33, 35, 37, 39, 36, 38, 40, 42, 44, 41, 43, 45, 47, 49, 46, 48, 50, 52, 54, 51, 53, 55, 57, 59, 56, 58, 60, 62, 64, 61, 63, 65, 67, 69, 66, 68, 70, 72, 74, 71, 73, 75, 77, 79, 76, 78, 80, 82, 84, 81, 83, 85, 87, 89, 86, 88, 90
Offset: 0

Views

Author

Eric Angelini and M. F. Hasler, Oct 23 2016

Keywords

Comments

A variant of A277616, which is defined in a similar way with squares > 1 instead of primes.
The steps a(n+1)-a(n) are either +2 or -3, after 10 terms we get a(n+10), and the first 10 terms are all numbers between 0 and 9: This sequence is obviously a permutation of the nonnegative integers, with a(n) = a(n-5) + 5 for all n > 5. The strictly positive variant (starting with a(1) = 1) is given by A065186.

Crossrefs

Programs

  • Mathematica
    Table[n - 2 + Mod[n - 3, 5], {n, 0, 500}] (* Fred Patrick Doty, Aug 03 2020 *)
  • PARI
    {u=[a=0];(chk(n)=(!#u||(n>u[1]&&!setsearch(u,n)))&&(u=setunion(u,[n]))&&!while(#u>1&&u[2]==u[1]+1,u=u[^1]));for(n=1,99,print1(a","); for(k=-primepi(a+!a-1),9e9, k||next; chk(a+sign(k)*prime(abs(k)))||next; a+=sign(k)*prime(abs(k));break))}
    
  • PARI
    A277618(n,i=[0,2,4,1,3])=i[n%#i+1]+n\#i*#i

Formula

a(n) = a(n-5) + 5 for all n > 5.
a(n) = A065186(n+1) - 1.
G.f.: x*(2*x^4 + 2*x^3 - 3*x^2 + 2*x + 2)/(x^6 - x^5 - x + 1). - Chai Wah Wu, Mar 30 2023

Extensions

Offset corrected by R. J. Mathar, Jun 19 2021