A052017 Primes with digits in ascending order that differ exactly by 1.
2, 3, 5, 7, 23, 67, 89, 4567, 23456789
Offset: 1
Crossrefs
Cf. A138141. - Omar E. Pol, Dec 07 2008
This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
Last 10 members of this finite sequence: a(45)=6543210 a(46)=7654321 a(47)=8765432 a(48)=9876543 a(49)=76543210 a(50)=87654321 a(51)=98765432 a(52)=876543210 a(53)=987654321 a(54)=9876543210
fQ[n_]:=Module[{id=IntegerDigits[n]}, n<10 || Union[Differences[id]]=={-1}]; Select[Range[0, 100000], fQ] (* Vladimir Joseph Stephan Orlovsky, Dec 29 2010 *) Sort[Flatten[With[{t=Range[9,0,-1]},Table[FromDigits/@Partition[t,n,1],{n,10}]]]] (* Harvey P. Dale, Oct 31 2013 *)
def ok(n): return "".join(sorted(str(n))) in "123456789" print([k for k in range(999) if ok(k)]) # Michael S. Branicky, Aug 04 2022
# alternate for generating full sequence instantly from itertools import permutations frags = ["123456789"[i:j] for i in range(9) for j in range(i+1, 10)] afull = sorted(int("".join(s)) for f in frags for s in permutations(f)) print(afull[:70]) # Michael S. Branicky, Aug 04 2022
12_3 = 5 is the largest prime number with strictly ascending digits for this base.
a(n)={forstep(k=n-1, 1, -1, forstep(j=n-k, 1, -1, my(t=fromdigits([j..j+k-1], n)); if(isprime(t), return(t)))); oo} \\ Andrew Howroyd, May 22 2021
Join[Range[9],Select[Range[350000],DigitCount[#,10,0]==0&&(Union[Differences[IntegerDigits[ #]]]=={1}||Union[Differences[IntegerDigits[#]]]=={-1})&]] (* Harvey P. Dale, Aug 13 2023 *)
def sgn(n): return 1 if n >= 0 else -1 def afull(): return sorted(int("".join(map(str, range(i, j+sgn(j-i), sgn(j-i))))) for i in range(1, 10) for j in range(1, 10)) print(afull()) # Michael S. Branicky, May 01 2022
Comments