login
A116068
Numbers k such that k has nondecreasing digits and the k-th prime has nonincreasing digits.
3
1, 2, 3, 4, 5, 11, 13, 14, 16, 18, 23, 25, 47, 67, 115, 116, 117, 119, 133, 135, 137, 147, 156, 166, 167, 168, 456, 566, 1166, 1167, 1168, 1178, 1179, 1199, 1225, 1226, 1229, 2479, 3566, 3569, 45567, 67999
OFFSET
1,2
COMMENTS
No more terms < 200000. - Stefan Steinerberger, Mar 19 2006
No more terms < 10 million. - Harvey P. Dale, Sep 25 2014
No more terms < 1 billion. - Michael S. Branicky, Jun 27 2022
EXAMPLE
prime(67999) = 855331.
MATHEMATICA
For[n = 1, n < 70000, n++, a := IntegerDigits[n]; c := 0; For[m = 1, m <= Length[a] -1, m++, If[a[[m]] > a[[m + 1]], c := 1; ]]; If[c == 0, a:=IntegerDigits[Prime[n]]; For[m = 1, m <= Length[a] - 1, m++, If[a[[m]] < a[[m + 1]], c := 1; ]]]; If[c == 0, Print[n]]] (* Stefan Steinerberger, Mar 19 2006 *)
nddQ[n_]:=Min[Differences[IntegerDigits[n]]]>-1&&Max[Differences[ IntegerDigits[ Prime[ n]]]]<1; Select[Range[70000], nddQ] (* Harvey P. Dale, Sep 25 2014 *)
PROG
(Python)
from sympy import sieve
from itertools import count, islice, combinations_with_replacement as mc
def ni(n): s = str(n); return s == "".join(sorted(s, reverse=True))
def bgen(d): yield from map(int, ("".join(m) for m in mc("123456789", d)))
def agen():
for d in count(1):
yield from (k for k in bgen(d) if ni(sieve[k]))
print(list(islice(agen(), 42))) # Michael S. Branicky, Jun 26 2022
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Giovanni Resta, Feb 13 2006
STATUS
approved