cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A328447 Smallest representative of the class of numbers having the same digits as n up to permutation.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, Oct 15 2019

Keywords

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

Examples

			a(201) = 102: largest digits go to the end, but the smallest nonzero digit must go first.
		

Crossrefs

Cf. A179239, A004186 (largest representative of the class of n).

Programs

  • 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 *)
  • 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