login
Number of 2's in n!.
14

%I #23 Jun 20 2021 18:24:04

%S 0,0,1,0,1,1,1,0,1,1,1,0,0,3,2,0,3,1,2,2,3,1,2,2,2,1,2,1,0,0,4,7,3,1,

%T 4,3,3,3,7,4,5,4,3,4,4,4,8,6,6,10,3,10,3,6,9,6,1,9,10,6,9,10,13,8,6,

%U 11,8,8,8,14,7,8,10,8,14,9,12,10,16,8,12,9,5,9,12,14,17,16,12,9,10,8,8,17,11,19,7,13,16,19,19,14

%N Number of 2's in n!.

%H Alois P. Heinz, <a href="/A079714/b079714.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Fa#factorial">Index entries for sequences related to factorial numbers</a>.

%F a(n) = A034886(n) - (A027869(n) + A079680(n) + A079684(n) + A079688(n) + A079690(n) + A079691(n) + A079692(n) + A079693(n) + A079694(n)). - _Reinhard Zumkeller_, Jan 27 2008

%p a:= n-> numboccur(2, convert(n!, base, 10)):

%p seq(a(n), n=0..101); # _Alois P. Heinz_, Apr 26 2021

%t Table[DigitCount[n!,10,2],{n,0,110}] (* _Harvey P. Dale_, Jun 20 2021 *)

%o (PARI) a(n) = #select(x->(x==2), digits(n!)); \\ _Michel Marcus_, Apr 26 2021

%Y Cf. A000142, A137579, A137580.

%Y Cf. A316863.

%K nonn,base,easy

%O 0,14

%A _Cino Hilliard_, Jan 31 2003

%E a(36) ff. corrected by _Georg Fischer_, Apr 26 2021