login
A009996
Numbers with digits in nonincreasing order.
30
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 22, 30, 31, 32, 33, 40, 41, 42, 43, 44, 50, 51, 52, 53, 54, 55, 60, 61, 62, 63, 64, 65, 66, 70, 71, 72, 73, 74, 75, 76, 77, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 110, 111, 200, 210, 211
OFFSET
1,3
COMMENTS
Base-10 representation Sum_{i=0..m} d(i)*10^i has d(m) >= d(m-1) >=... >= d(1) >= d(0).
These numbers might be called "Nialpdromes".
A004186(a(n)) = a(n). -Reinhard Zumkeller,Oct 31 2007
LINKS
D. Applegate, M. LeBrun, and N. J. A. Sloane,Dismal Arithmetic,J. Int. Seq. 14 (2011) # 11.9.8.
David A. Corneth,Table of n, a(n) for n = 1..20000,Jun 03 2014
Eric Weisstein's World of Mathematics,Digit
FORMULA
Binomial(n+k,k) = (n+k)!/(n!*k!). d(i) is the i-th digit of a(n). q is the number of digits of a(n). Find the highest m such that C(10 + m, 10) - m + 1 <= n. a(n) has m+1 digits. Set n = n - C(10+m,10). Find the highest d(m+1), then d(m), then..., then d(1) each iteration such that C(d(m+1)+m+1,1+m+1)<=n. Then set n = n-C(d(m+1)+m+1,m+2). If n = 0 then stop. All remaining digits are 0.
EXAMPLE
As 10000 = C(10+6,10) - 6 + C(7+6,1+6) + C(5+5,1+5) + C(4+4,1+4) + C(3+3,1+3) + C(1+2,1+2) + C(0+1,1+1), C(0+0,1+0), a(10000) = 7543100.
MATHEMATICA
Select[Range[0, 211], GreaterEqual@@IntegerDigits[#]&] (*Ray Chandler,Oct 25 2011 *)
PROG
(PARI) is(n)=my(d=digits(n)); for(i=2, #d, if(d[i]>d[i-1], return(0))); 1 \\Charles R Greathouse IV,Jan 02 2014
(PARI) \\ This program is optimized for fast calculation of a(n) for large n.
a(n)={my(q, m=10, i, r=0); n--; while(binomial(m+1, 10)<=n+m-9, m++); n-=binomial(m, 10); n+=m-9; q=m-9; i=q; while(n>0, m=i; while(binomial(m+1, i)<=n, m++); r=10*r+m+1-i; n-=binomial(m, i); i--; ); z=q-#digits(r); r*=10^z; r} \\David A. Corneth,Jun 01 2014
(PARI) \\recursive--feed an element a(n)>0 and it gives a(n+1).
nxt(n)={my(r, d=digits(n), y, t); if(d[#d]!=9, y=1; while(y-#d-1&&d[y]==9, y++); t=#d; forstep(i=t, y+1, -1, if(d[i-1]!=d[i], t=i-1; break)); if(t!=#d, d[t+1]++; for(i=t+2, #d, d[i]=0), d[y]++; for(i=y+1, #d, d[i]=0)); r=d, d=vector(#d+1); d[1]=1; for(i=2, #d, d[i]=0); r=d); sum(i=1, #r, 10^(#r-i)*r[i])} \\David A. Corneth,Jun 01 2014
(Python)
from itertools import count, islice, combinations_with_replacement as mc
def agen(): # generator of terms
yield 0
for d in count(1):
ni = (int( "".join(m)) for m in mc( "9876543210", d) if m[0]!= "0" )
yield from sorted(ni)
print(list(islice(agen(), 70))) #Michael S. Branicky,Jun 24 2022
CROSSREFS
KEYWORD
nonn,base,look
EXTENSIONS
Corrected byRick L. Shepherd,Jun 06 2002
STATUS
approved