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.

User: Ben White

Ben White's wiki page.

Ben White has authored 1 sequences.

A354973 a(0)=0; for n > 0, a(n) = 2*a(n-1) if n-1 is prime, a(n-1) + 1 otherwise.

Original entry on oeis.org

0, 1, 2, 4, 8, 9, 18, 19, 38, 39, 40, 41, 82, 83, 166, 167, 168, 169, 338, 339, 678, 679, 680, 681, 1362, 1363, 1364, 1365, 1366, 1367, 2734, 2735, 5470, 5471, 5472, 5473, 5474, 5475, 10950, 10951, 10952, 10953, 21906, 21907, 43814, 43815, 43816, 43817, 87634
Offset: 0

Author

Ben White, Jun 14 2022

Keywords

Examples

			5 is prime, so a(6) = 2*a(5) = 2*9 = 18.
6 is not prime, so a(7) = a(6) + 1 = 18 + 1 = 19.
		

Crossrefs

Cf. A110299.

Programs

  • Mathematica
    a[0] = 0; a[n_] := a[n] = If[PrimeQ[n - 1], 2*a[n - 1], a[n - 1] + 1]; Array[a, 50, 0] (* Amiram Eldar, Jun 21 2022 *)
  • PARI
    a(n) = my(k=primepi(n-1)); fromdigits(primes(k),2) - 1<Kevin Ryde, Jun 22 2022
  • Python
    from sympy import isprime
    a = [0]; [a.append(2*a[-1] if isprime(n) else a[-1]+1) for n in range(48)]
    print(a) # Michael S. Branicky, Jun 21 2022
    

Formula

a(n) = A110299(k) - 2^k + n + 1, where k = primepi(n-1) and taking A110299(0) = 0. - Kevin Ryde, Jun 22 2022