login
A328447
Smallest representative of the class of numbers having the same digits as n up to permutation.
9
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, 67, 68, 69, 70, 17, 27, 37, 47, 57, 67
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
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
Cf. A179239, A004186 (largest representative of the class of n).
Sequence in context: A291769 A167129 A348287 * A107602 A272215 A323366
KEYWORD
nonn,base,easy,look
AUTHOR
M. F. Hasler, Oct 15 2019
STATUS
approved