login
Sum of the first n n-digit primes.
2

%I #22 Sep 01 2022 18:52:15

%S 2,24,311,4062,50153,600240,7000409,80000960,900000729,10000000754,

%T 110000001257,1200000001154,13000000002051,140000000003318,

%U 1500000000003685,16000000000004454,170000000000009723,1800000000000004696,19000000000000007691,200000000000000006828

%N Sum of the first n n-digit primes.

%H Alois P. Heinz, <a href="/A119491/b119491.txt">Table of n, a(n) for n = 1..300</a> (first 100 terms from Robert G. Wilson v)

%e The first three three-digit primes are: 101, 103 and 107. Their sum is 311. Hence a(3) is 311.

%p with(numtheory): a:=n->add(ithprime(pi(nextprime(10^(n-1)))+i),i=0..n-1): seq(a(n),n=1..9); # _Emeric Deutsch_, Jul 29 2006

%t NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ@k, k++ ]; k]; f[n_] := Plus @@ Rest@NestList[NextPrim, 10^(n - 1), n]; Array[f, 18] (* _Robert G. Wilson v_, Aug 01 2006 *)

%t Total/@Table[Rest[NestList[NextPrime[#]&,10^(n-1),n]],{n,30}] (* _Harvey P. Dale_, Sep 01 2022 *)

%o (Python)

%o from sympy import nextprime

%o def a(n):

%o s = p = nextprime(10**(n-1))

%o for n in range(n-1): p = nextprime(p); s += p

%o return s

%o print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Feb 24 2021

%Y Cf. A114053.

%K base,nonn

%O 1,1

%A _Tanya Khovanova_, Jul 26 2006

%E a(5)-a(8) from _Emeric Deutsch_, Jul 29 2006

%E a(9)-a(18) from _Robert G. Wilson v_, Aug 01 2006