OFFSET
1,3
COMMENTS
a(4091131) = 9876543210 is the last term.
Also 0 together with positive integers having k distinct digits and the difference between the largest and the smallest digit equal to k-1. - David A. Corneth, Dec 26 2017
LINKS
Ely Golden, Table of n, a(n) for n = 1..10000
FORMULA
If zero is excluded, the number of terms with k digits, 1 <= k <= 10, is (11-k)*k! - (k-1)!. - Franklin T. Adams-Watters, Aug 01 2012
MATHEMATICA
lst = {}; Do[If[Times @@ Differences@Sort@IntegerDigits[n] == 1, AppendTo[lst, n]], {n, 0, 675}]; lst (* Arkadiusz Wesolowski, Aug 01 2012 *)
Join[Range[0, 9], Select[Range[1000], Union[Differences[Sort[ IntegerDigits[ #]]]] == {1}&]] (* Harvey P. Dale, Jan 14 2015 *)
PROG
(PARI) is(n)=my(v=vecsort(eval(Vec(Str(n))))); for(i=2, #v, if(v[i]!=1+v[i-1], return(0))); 1
(PARI) is(n) = if(!n, return(1)); my(d = digits(n), v = vecsort(d, , 8)); #d == #v && v[#v] - v[1] == #v - 1
(Python)
# Ely Golden, Dec 26 2017
def consecutive(li):
for i in range(len(li)-1):
if(li[i+1]!=1+li[i]): return False
return True
def sorted_digits(n):
lst=[]
while(n>0):
lst+=[n%10] ; n//=10
lst.sort() ; return lst
j=0
for i in range(1, 10001):
while(not consecutive(sorted_digits(j))): j+=1
print(str(i)+" "+str(j)) ; j+=1
(Python) # alternate for generating full sequence in seconds
from itertools import permutations as perms
frags = ["0123456789"[i:j] for i in range(10) for j in range(i+1, 11)]
afull = sorted(set(int("".join(s)) for f in frags for s in perms(f)))
print(afull[:70]) # Michael S. Branicky, Aug 04 2022
CROSSREFS
KEYWORD
nonn,base,fini
AUTHOR
Tanya Khovanova and Charles R Greathouse IV, Jul 31 2012
EXTENSIONS
Name edited by Felix Fröhlich, Dec 26 2017
STATUS
approved