A055098 Number of distinct anagrams of digits of n without leading zeros.
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, 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, 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
Offset: 1
Examples
a(101)=2 since the digits of 101 can be ordered 101 or 110 (but not 011).
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Programs
-
Haskell
import Data.List (permutations, nub) a055098 n = length $ nub $ filter ((> '0') . head) $ permutations $ show n -- Reinhard Zumkeller, Aug 14 2011
-
Mathematica
a[n_] := Length[ DeleteCases[ Permutations[ IntegerDigits[n]], {0 .., }]]; Table[a[n], {n, 1, 102}] (* Jean-François Alcover, Nov 30 2011 *)
-
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
-
Python
from math import factorial, prod def a(n): s = str(n); d, c = len(s), [s.count(str(i)) for i in range(10)] return (d-c[0])*factorial(d-1)//prod(map(factorial, c)) print([a(n) for n in range(1, 50)]) # Michael S. Branicky, Aug 24 2022
Formula
a(n) = O(n/(log n)^(9/2)). - Charles R Greathouse IV, Aug 24 2022