login
a(n) is the mode of the digits of n! not counting trailing zeros (using -1 if multimodal).
2

%I #29 Sep 16 2025 20:17:07

%S 1,1,2,6,-1,-1,-1,-1,-1,8,8,9,0,2,-1,-1,8,-1,7,-1,-1,-1,7,8,3,1,6,8,

%T -1,-1,8,2,3,8,9,-1,9,-1,0,8,1,-1,-1,3,8,6,-1,1,7,2,6,-1,8,3,-1,5,4,2,

%U -1,8,4,0,2,6,-1,2,4,6,1,2,8,8,8,0,2,4,-1,8,2,1,5,7,4,-1,1,0

%N a(n) is the mode of the digits of n! not counting trailing zeros (using -1 if multimodal).

%C Inspired by A356758.

%C If we were to count trailing zeros, then would have a(n) = 0 for all n >= 34. Therefore we only consider the decimal digits of A004154(n).

%C Conjecture: excluding -1, as n -> oo, all digits occur equally often.

%H Robert Israel, <a href="/A375348/b375348.txt">Table of n, a(n) for n = 0..6000</a>

%e a(0) = a(1) = 1 because 0! = 1! = 1 and 1 is the only digit present;

%e a(4) = -1 since 4! = 24 and there are only two digits appearing with the same frequency, 2 and 4.

%e a(14) = -1 because 14! = 87178291200 and, not counting the two trailing 0's, there are two 1's, two 2's, two 7's, and two 8's.

%p f:= proc(n) local L, j;

%p L:= convert(n!, base, 10);

%p for j from 1 while L[j] = 0 do od:

%p L:= Statistics:-Tally(L[j...-1]);

%p L:= sort(L, (a, b) -> rhs(a) > rhs(b));

%p if nops(L) >= 2 and rhs(L[2]) = rhs(L[1]) then -1 else lhs(L[1]) fi

%p end proc:

%p map(f, [$0..100]); # _Robert Israel_, Sep 15 2025

%t a[n_] := If[Length[c=Commonest[IntegerDigits[n! / 10^IntegerExponent[n!]]]] > 1, -1, c[[1]]]; Array[a, 86, 0]

%o (Python)

%o from collections import Counter

%o from sympy import factorial

%o def A375348(n): return -1 if len(k:=Counter(str(factorial(n)).rstrip('0')).most_common(2)) > 1 and k[0][1]==k[1][1] else int(k[0][0]) # _Chai Wah Wu_, Sep 15 2024

%Y Cf. A004154, A027869, A031144, A034886, A061010, A137579, A137580, A356758, A375575.

%K base,sign

%O 0,3

%A _Stefano Spezia_ and _Robert G. Wilson v_, Aug 12 2024