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.

A378500 a(1) = 2, then a(n) = a(n-1) - 2 for n even, a(n) = a(n-1) + 3 for n an odd prime or odd prime power, and a(n) = a(n-1) + 2 otherwise.

Original entry on oeis.org

2, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7, 5, 8, 6, 8, 6, 9, 7, 10, 8, 10, 8, 11, 9, 12, 10, 13, 11, 14, 12, 15, 13, 15, 13, 15, 13, 16, 14, 16, 14, 17, 15, 18, 16, 18, 16, 19, 17, 20, 18, 20, 18, 21, 19, 21, 19, 21, 19, 22, 20, 23, 21, 23, 21, 23, 21, 24, 22, 24, 22, 25
Offset: 1

Views

Author

Bill McEachen, Nov 30 2024

Keywords

Comments

Asymptotically the sequence should reach long periods of stasis, with rare increases with each new prime so as to yield a strict permutation of the positive integers if duplicates are removed.

Examples

			3 is prime so a(3) = a(2) + 3 = 0 + 3 = 3. 4 is even so a(4) = a(3) - 2 = 3 - 2 = 1.
		

Programs

  • Mathematica
    Module[{n = 1}, NestList[# + Which[EvenQ[++n], -2, PrimePowerQ[n], 3, True, 2] &, 2, 100]] (* Paolo Xausa, Dec 06 2024 *)
  • PARI
    first(n)=my(v=vector(n)); v[1]=2; for(k=2,n, v[k]=v[k-1]+if(k%2==0, -2, isprimepower(k), 3, 2)); v \\ Charles R Greathouse IV, Dec 01 2024

Formula

a(n) = a(n-1) - 2 for n even.
a(n) = a(n-1) + 3 for n an odd prime or odd prime power.
a(n) = a(n-1) + 2 for n an odd composite not a prime power.
a(n) ~ n/log n. - Charles R Greathouse IV, Dec 01 2024

Extensions

Corrected by Charles R Greathouse IV, Dec 01 2024