A346180 a(n) = prime(n) + n if n is prime, a(n) = prime(n) otherwise.
2, 5, 8, 7, 16, 13, 24, 19, 23, 29, 42, 37, 54, 43, 47, 53, 76, 61, 86, 71, 73, 79, 106, 89, 97, 101, 103, 107, 138, 113, 158, 131, 137, 139, 149, 151, 194, 163, 167, 173, 220, 181, 234, 193, 197, 199, 258, 223, 227, 229, 233, 239, 294, 251, 257, 263, 269, 271
Offset: 1
Keywords
Examples
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.
Programs
-
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 *)
-
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
Comments