OFFSET
0,5
COMMENTS
In the following Python program, the algorithm based on the sieve of Eratosthenes is used to generate the primes.
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..100000
Wikipedia, Sieve Of Eratosthenes
EXAMPLE
For n=15, the primes < n are 2,3,5,7,11,13. So the concatenated string is "23571113", which has length=8. a(n)=8.
MATHEMATICA
Join[{0}, Accumulate[Table[If[PrimeQ[n], IntegerLength[n], 0], {n, 0, 60}]]] (* Harvey P. Dale, Mar 04 2023 *)
PROG
(Python)
def p(n):
if n<=2:
return 0
s=1
l = [True] * n
for i in range(3, int(n**0.5)+1, 2):
if l[i]:
l[i*i::2*i]=[False]*((n-i*i-1)//(2*i)+1)
for i in range(3, n, 2):
if l[i]:
s+=len(str(i))
return s
for i in range(0, 100001):
print(f'{i} {p(i)}')
CROSSREFS
KEYWORD
nonn,base,changed
AUTHOR
Indranil Ghosh, Dec 02 2016
STATUS
approved