OFFSET
1,1
COMMENTS
For n > 0, take the n-th prime and only add n to it if n is prime itself.
EXAMPLE
a(1) = 2 = 2+0; 2 is the first prime. 1 is not prime and thus is not added.
a(2) = 5 = 3+2; 3 is the second prime, and since 2 is also prime, add 2.
a(3) = 8 = 5+3; 5 is the third prime, and since 3 is also prime, add 3.
MATHEMATICA
Table[Prime@n+Boole@PrimeQ[n]n, {n, 60}] (* Giorgos Kalogeropoulos, Jul 29 2021 *)
Table[If[PrimeQ[n], Prime[n]+n, Prime[n]], {n, 60}] (* Harvey P. Dale, Nov 20 2022 *)
PROG
(PARI) a(n) = prime(n) + isprime(n)*n; \\ Michel Marcus, Jul 12 2021
(Python)
from sympy import isprime, prime
def a(n): return prime(n) + n*isprime(n)
print([a(n) for n in range(1, 59)]) # Michael S. Branicky, Jul 29 2021
(Python) # faster version for initial segment of sequence
from sympy import isprime, prime, primerange
def aupton(nn): return [p + n*isprime(n) for n, p in enumerate(primerange(1, prime(nn)+1), start=1)]
print(aupton(10000)) # Michael S. Branicky, Jul 29 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Samuel Vilz, Jul 09 2021
STATUS
approved