login
Number of distinct anagrams of digits of n without leading zeros.
5

%I #22 Oct 11 2022 14:11:33

%S 1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,1,2,1,2,2,2,2,2,2,2,1,2,2,1,2,

%T 2,2,2,2,2,1,2,2,2,1,2,2,2,2,2,1,2,2,2,2,1,2,2,2,2,1,2,2,2,2,2,1,2,2,

%U 2,1,2,2,2,2,2,2,1,2,2,1,2,2,2,2,2,2,2,1,2,1,2,2,2,2,2,2,2,2,1,1,2,4

%N Number of distinct anagrams of digits of n without leading zeros.

%H Reinhard Zumkeller, <a href="/A055098/b055098.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = O(n/(log n)^(9/2)). - _Charles R Greathouse IV_, Aug 24 2022

%e a(101)=2 since the digits of 101 can be ordered 101 or 110 (but not 011).

%t a[n_] := Length[ DeleteCases[ Permutations[ IntegerDigits[n]], {0 .., __}]]; Table[a[n], {n, 1, 102}] (* _Jean-François Alcover_, Nov 30 2011 *)

%o (Haskell)

%o import Data.List (permutations, nub)

%o a055098 n = length $ nub $ filter ((> '0') . head) $ permutations $ show n

%o -- _Reinhard Zumkeller_, Aug 14 2011

%o (PARI) a(n)={my(v=digits(n), f=vector(10), n=#v); for(i=1, #v, f[1+v[i]]++); (1 - f[1]/n) * n! / prod(i=1, #f, f[i]!)} \\ _Andrew Howroyd_, Jan 27 2020

%o (Python)

%o from math import factorial, prod

%o def a(n):

%o s = str(n); d, c = len(s), [s.count(str(i)) for i in range(10)]

%o return (d-c[0])*factorial(d-1)//prod(map(factorial, c))

%o print([a(n) for n in range(1, 50)]) # _Michael S. Branicky_, Aug 24 2022

%Y Cf. A046810, A047726.

%K base,easy,nice,nonn

%O 1,12

%A _Henry Bottomley_, Apr 19 2000