OFFSET
0,3
COMMENTS
EXAMPLE
a(0) = a(1) = 1 because 0! = 1! = 1 and 1 is the only digit present;
a(4) = -1 since 4! = 24 and there are two least frequent digits, 2 and 4.
a(14) = 9 because 14! = 87178291200 and, not counting the two trailing 0's, there are two 1's, two 2's, two 7's, two 8's but only one 9.
MAPLE
f:= proc(n) local L, j;
L:= convert(n!, base, 10);
for j from 1 while L[j] = 0 do od:
L:= Statistics:-Tally(L[j...-1]);
L:= sort(L, (a, b) -> rhs(a) < rhs(b));
if nops(L) >= 2 and rhs(L[2]) = rhs(L[1]) then -1 else lhs(L[1]) fi
end proc:
map(f, [$0..100]); # Robert Israel, Sep 02 2024
MATHEMATICA
Rarest[lst_] := MinimalBy[ Tally[lst], Last][[All, 1]]; a[n_] := If[ Length[c = Rarest[ IntegerDigits[n!/10^IntegerExponent[n!, 10]] ]] >1, -1, c[[1]]]; Array[a, 80, 0]
PROG
(Python)
from collections import Counter
from sympy import factorial
def A375575(n): return -1 if len(k:=Counter(str(factorial(n)).rstrip('0')).most_common()) > 1 and k[-1][1]==k[-2][1] else int(k[-1][0]) # Chai Wah Wu, Sep 15 2024
CROSSREFS
KEYWORD
base,easy,sign
AUTHOR
Stefano Spezia and Robert G. Wilson v, Aug 19 2024
STATUS
approved