login
Number of primes less than 10^n with digits in nonincreasing order.
2

%I #45 Jul 24 2021 01:41:18

%S 0,4,14,49,125,296,646,1304,2459,4543,7882,13272,21856,34934,53446,

%T 82055,121322,175498,251714,354810,488440,676065,914834,1220629,

%U 1627770,2135954,2759889,3590609,4602572,5830588,7386200,9266652,11469407,14314939,17658240

%N Number of primes less than 10^n with digits in nonincreasing order.

%C Number of primes with at most n digits arranged in nonincreasing order.

%H Michael S. Branicky, <a href="/A345326/b345326.txt">Table of n, a(n) for n = 0..42</a>

%H <a href="/index/Pri#primepop">Index entries for sequences related to numbers of primes in various ranges</a>

%t Table[Length@Select[Prime@Range[PrimePi[10^n]],OrderedQ@Reverse@IntegerDigits@#&],{n,0,7}] (* _Giorgos Kalogeropoulos_, Jul 22 2021 *)

%o (Python)

%o from sympy import isprime

%o from itertools import accumulate, combinations_with_replacement as mc

%o def numwithdigs(d):

%o if d == 0: return 0

%o nonincreasing = (int("".join(m)) for m in mc("987654321", d))

%o return len(list(filter(isprime, nonincreasing)))

%o def aupto(nn): return list(accumulate(numwithdigs(d) for d in range(nn+1)))

%o print(aupto(14)) # _Michael S. Branicky_, Jul 22 2021

%Y Cf. A000040, A006880, A028867, A345325.

%K nonn,base,hard

%O 0,2

%A _Ilya Gutkovskiy_, Jul 22 2021

%E a(12)-a(34) from _Michael S. Branicky_, Jul 22 2021