A348287 Arrange nonzero digits of n in increasing order then append the zeros.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 12, 22, 23, 24, 25, 26, 27, 28, 29, 30, 13, 23, 33, 34, 35, 36, 37, 38, 39, 40, 14, 24, 34, 44, 45, 46, 47, 48, 49, 50, 15, 25, 35, 45, 55, 56, 57, 58, 59, 60, 16, 26, 36, 46, 56, 66
Offset: 0
Examples
a(1010) = 1100, a(1234567890) = 1234567890, a(9876543210) = 1234567890.
Programs
-
Mathematica
a[n_] := 10^DigitCount[n, 10, 0] * FromDigits[Sort[IntegerDigits[n]]]; Array[a, 100, 0] (* Amiram Eldar, Oct 10 2021 *)
-
PARI
a(n) = fromdigits(vecsort(digits(n), x->if(x,x,10)));
-
Python
def a(n): s = str(n); return int("".join(sorted(s)))*10**s.count('0') print([a(n) for n in range(68)]) # Michael S. Branicky, Oct 10 2021
-
Ruby
p Array.new(40) { |n| n.to_s.gsub('0','a').split(//).sort.join.gsub('a','0').to_i }
Comments