OFFSET
1,2
COMMENTS
For k in 1 <= k <= n, add k if k is prime, otherwise add 1. For example a(6) = 1 + 2 + 3 + 1 + 5 + 1 = 13.
LINKS
Antti Karttunen, Table of n, a(n) for n = 1..10000
FORMULA
MATHEMATICA
a[n_] := Sum[k^Boole[PrimeQ[k]], {k, 1, n}]; Array[a, 60] (* Amiram Eldar, Nov 11 2021 *)
PROG
(PARI) a(n) = sum(k=1, n, if (isprime(k), k, 1)); \\ Michel Marcus, Nov 11 2021
(Python)
from sympy import primerange
def A349214(n):
p = list(primerange(2, n+1))
return n-len(p)+sum(p) # Chai Wah Wu, Nov 11 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Wesley Ivan Hurt, Nov 10 2021
STATUS
approved