%I #12 Jun 27 2022 19:07:27
%S 1,2,3,4,5,11,20,21,64,82,83,84,86,98,100,331,720,730,732,810,821,843,
%T 921,933,940,942,970,982,983,1100,5540,6442,6542,6644,7331,7411,7433,
%U 7440,7442,7443,7511,7520,7530,7531,7620,7630,7641,7642,7644,8210,8500,8510
%N Numbers k such that both k and the k-th prime have nonincreasing digits.
%H Michael S. Branicky, <a href="/A116067/b116067.txt">Table of n, a(n) for n = 1..82</a> (all terms < 10^8)
%e prime(7531) = 76543.
%t Select[Range[9000],Max[Differences[IntegerDigits[#]]]< 1 && Max[ Differences[ IntegerDigits[Prime[#]]]]<1&] (* _Harvey P. Dale_, Oct 11 2021 *)
%o (Python)
%o from sympy import sieve
%o from itertools import count, islice, combinations_with_replacement as mc
%o def ni(n): s = str(n); return s == "".join(sorted(s, reverse=True))
%o def bgen(d):
%o ni = map(int, ("".join(m) for m in mc("9876543210", d)))
%o yield from sorted(k for k in ni if k != 0)
%o def agen():
%o for d in count(1):
%o yield from (k for k in bgen(d) if ni(sieve[k]))
%o print(list(islice(agen(), 52))) # _Michael S. Branicky_, Jun 26 2022
%Y Cf. A116066, A116068, A116069.
%K nonn,base
%O 1,2
%A _Giovanni Resta_, Feb 13 2006
%E a(51) and beyond from _Michael S. Branicky_, Jun 26 2022
|