login
a(n) = f(n-1,n) + 10*(n-1), where f(a,b) is the number of primes in the range [10*a,10*b].
1

%I #25 May 24 2021 07:59:44

%S 4,14,22,32,43,52,62,73,82,91,104,111,121,133,141,152,162,172,181,194,

%T 200,211,223,232,241,252,262,272,282,291,301,313,320,332,342,352,361,

%U 372,382,391,402,411,421,433,442,451,463,471,481,492,502,510,522,530,542,551,562,572,581,592,602,613,620,631,643

%N a(n) = f(n-1,n) + 10*(n-1), where f(a,b) is the number of primes in the range [10*a,10*b].

%F a(n) = A038800(n-1) + 10*(n-1). - _Michel Marcus_, Jan 11 2018

%e The first term has the number of prime numbers between 0 and 9: 4. Since the numbers in this first range are smaller than 10, the left digit would be a zero (not represented). The second term has the number of prime numbers between 10 and 19 (4) and since it was counted in the range between 10 and 19 it represents this range with the one in the first digit in the left: 14. The third element is 22 as there are 2 primes between 20 and 29. And so on. Larger element: there is only one prime between 120 and 129, hence a(13)=121.

%t Block[{p = 1, k}, k = 10^p; Array[Apply[Subtract, PrimePi[{k #, k (# - 1)}]] + (# - 1) k &, 67]] (* _Michael De Vlieger_, Jan 11 2018 *)

%o (Python)

%o # Generates all elements of the sequence smaller than 'last'

%o last = 1000

%o p=[2]

%o c=1

%o for i in range(3,last+2,2):

%o prime = True

%o for j in p:

%o if i%j == 0:

%o prime=False;

%o break;

%o if prime:

%o p.append(i)

%o c = c + 1

%o ii = (i//10)*10

%o if i-ii == 1:

%o if prime:

%o print(ii-10+c-1, end=',')

%o c = 1

%o else:

%o print(ii-10+c, end=',')

%o c = 0

%Y Cf. A038800.

%K nonn

%O 1,1

%A _Luis F.B.A. Alexandre_, Jan 10 2018

%E Edited by _N. J. A. Sloane_, Jan 28 2018