OFFSET
0,3
COMMENTS
Sort the digits in increasing order. If the list starts with a digit 0, move the smallest nonzero digit to the front.
Every term is in A179239. - David A. Corneth, Oct 17 2019
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
EXAMPLE
a(201) = 102: largest digits go to the end, but the smallest nonzero digit must go first.
MAPLE
f:= proc(n) local L, i, t;
L:= sort(convert(n, base, 10));
if L[1]=0 then
t:= numboccur(0, L)+1;
L:= [L[t], op(L[1..t-1]), op(L[t+1..-1])];
fi;
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
f(0):= 0:
map(f, [$0..100]);
MATHEMATICA
Array[FromDigits@ If[First@ # == 0, Flatten@ MapAt[Reverse, TakeDrop[#, 2], 1], #] &@ Sort@ IntegerDigits[#] &, 67] (* Michael De Vlieger, Oct 17 2019 *)
PROG
(PARI) A328447(n)={if(n=vecsort(digits(n)), n[1]|| for(k=2, #n, n[k]&&[n[1]=n[k], n[k]=0, break])); fromdigits(n)}
(Python)
def A328447(n):
if n == 0: return 0
s = str(n)
l, s = len(s), ''.join(sorted(s.replace('0', '')))
return int(s[0]+'0'*(l-len(s))+s[1:]) # Chai Wah Wu, Dec 06 2021
CROSSREFS
KEYWORD
AUTHOR
M. F. Hasler, Oct 15 2019
STATUS
approved