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.

A058049 Numbers k such that the sum of the digits of the first k primes is a prime.

This page as a plain text file.
%I A058049 #20 Aug 05 2025 05:09:42
%S A058049 1,2,4,5,6,7,8,11,12,14,23,33,43,45,48,64,69,72,73,77,87,94,95,96,98,
%T A058049 110,118,124,130,133,140,148,152,154,157,162,171,174,178,181,196,200,
%U A058049 201,206,210,212,219,232,241,244,253,257,267,269,272,277,299,304,306
%N A058049 Numbers k such that the sum of the digits of the first k primes is a prime.
%C A058049 What is intriguing about this sequence is that the number of primes less than 10^m is of the same magnitude as A006880. Here they begin 7, 25, 122, 934.
%H A058049 Z. Stankova-Frenkel and J. West, <a href="https://arxiv.org/abs/math/0106073">Explicit enumeration of 321,hexagon-avoiding permutations</a>, arXiv:math/0106073 [math.CO], 2001.
%e A058049 5 is a term because sum of digits of first 5 primes, 2+3+5+7+(1+1)=19, is prime.
%e A058049 a(5) = 6 because in A051351(6) = 2 + 3 + 5 + 7 + 2 (sum of eleven's digits) + 4 (sum of thirteen's digits) which equals the sum of the digits through the sixth prime = 23 which itself is a prime.
%t A058049 s = 0; Do[ s = s + Apply[ Plus, RealDigits[ Prime[ n ]] [[1]] ]; If[ PrimeQ[ s ], Print[ n ] ], {n, 1, 1000} ]
%o A058049 (PARI) isok(n) = isprime(sum(k=1, n, sumdigits(prime(k)))); \\ _Michel Marcus_, Mar 11 2017
%o A058049 (Python)
%o A058049 from sympy import isprime, nextprime
%o A058049 def sd(n): return sum(map(int, str(n)))
%o A058049 def aupto(limit):
%o A058049     alst, k, p, s = [], 1, 2, 2
%o A058049     while k <= limit:
%o A058049         if isprime(s): alst.append(k)
%o A058049         k += 1; p = nextprime(p); s += sd(p)
%o A058049     return alst
%o A058049 print(aupto(306)) # _Michael S. Branicky_, Jul 18 2021
%Y A058049 Corresponding primes: A104247. Primes: A000040, sum of digits of primes: A007605.
%Y A058049 Cf. A051351.
%K A058049 nonn,base
%O A058049 1,2
%A A058049 _Robert G. Wilson v_, Nov 18 2000
%E A058049 Edited by _R. J. Mathar_, Aug 04 2008