A004185 Arrange digits of n in increasing order, then (for n > 0) omit the zeros.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 12, 22, 23, 24, 25, 26, 27, 28, 29, 3, 13, 23, 33, 34, 35, 36, 37, 38, 39, 4, 14, 24, 34, 44, 45, 46, 47, 48, 49, 5, 15, 25, 35, 45, 55, 56, 57, 58, 59, 6, 16, 26, 36, 46, 56, 66, 67, 68, 69, 7, 17, 27, 37, 47
Offset: 0
Examples
a(19) = 19 because the digits are already in increasing order. a(20) = 2 because the digits of 20 are 2 and 0, which in increasing order are 0 and 2, but since zero-padding is not allowed on the left, the zero digit is dropped and we are left with 2. a(21) = 12 because the digits of 21 are 2 and 1, which in increasing order are 1 and 2.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Crossrefs
Programs
-
Haskell
import Data.List (sort) a004185 n = read $ sort $ show n :: Integer -- Reinhard Zumkeller, Aug 10 2011
-
Magma
A004185:=func
; [n eq 0 select 0 else A004185(n): n in [0..57]]; // Bruno Berselli, Apr 03 2012 -
Maple
A004185 := proc(n) local dgs; convert(n,base,10) ; dgs := sort(%,`>`) ; add( op(i,dgs)*10^(i-1),i=1..nops(dgs)) ; end proc: seq(A004185(n),n=0..20) ; # R. J. Mathar, Jul 26 2015
-
Mathematica
FromDigits[Sort[DeleteCases[IntegerDigits[#], 0]]]&/@Range[0, 60] (* Harvey P. Dale, Nov 29 2011 *)
-
PARI
a(n)=fromdigits(vecsort(digits(n))) \\ Charles R Greathouse IV, Feb 06 2017
-
Python
def A004185(n): return int(''.join(sorted(str(n))).replace('0','')) if n > 0 else 0 # Chai Wah Wu, Nov 10 2015
Comments