%I #26 Dec 06 2021 03:15:36
%S 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,
%T 26,27,28,29,30,13,23,33,34,35,36,37,38,39,40,14,24,34,44,45,46,47,48,
%U 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
%N Smallest representative of the class of numbers having the same digits as n up to permutation.
%C Sort the digits in increasing order. If the list starts with a digit 0, move the smallest nonzero digit to the front.
%C Every term is in A179239. - _David A. Corneth_, Oct 17 2019
%H Robert Israel, <a href="/A328447/b328447.txt">Table of n, a(n) for n = 0..10000</a>
%e a(201) = 102: largest digits go to the end, but the smallest nonzero digit must go first.
%p f:= proc(n) local L,i,t;
%p L:= sort(convert(n,base,10));
%p if L[1]=0 then
%p t:= numboccur(0,L)+1;
%p L:= [L[t],op(L[1..t-1]),op(L[t+1..-1])];
%p fi;
%p add(L[-i]*10^(i-1),i=1..nops(L))
%p end proc:
%p f(0):= 0:
%p map(f, [$0..100]);
%t Array[FromDigits@ If[First@ # == 0, Flatten@ MapAt[Reverse, TakeDrop[#, 2], 1], #] &@ Sort@ IntegerDigits[#] &, 67] (* _Michael De Vlieger_, Oct 17 2019 *)
%o (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)}
%o (Python)
%o def A328447(n):
%o if n == 0: return 0
%o s = str(n)
%o l, s = len(s), ''.join(sorted(s.replace('0','')))
%o return int(s[0]+'0'*(l-len(s))+s[1:]) # _Chai Wah Wu_, Dec 06 2021
%Y Cf. A179239, A004186 (largest representative of the class of n).
%K nonn,base,easy,look
%O 0,3
%A _M. F. Hasler_, Oct 15 2019
|