OFFSET
0,3
FORMULA
a(n) = A110299(k) - 2^k + n + 1, where k = primepi(n-1) and taking A110299(0) = 0. - Kevin Ryde, Jun 22 2022
EXAMPLE
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.
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 *)
PROG
(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
(PARI) a(n) = my(k=primepi(n-1)); fromdigits(primes(k), 2) - 1<<k + n + 1; \\ Kevin Ryde, Jun 22 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Ben White, Jun 14 2022
STATUS
approved