A136692 Final nonzero digit of n! in base 5.
1, 1, 2, 1, 4, 4, 4, 3, 4, 1, 2, 2, 4, 2, 3, 4, 4, 3, 4, 1, 4, 4, 3, 4, 1, 1, 1, 2, 1, 4, 4, 4, 3, 4, 1, 2, 2, 4, 2, 3, 4, 4, 3, 4, 1, 4, 4, 3, 4, 1, 2, 2, 4, 2, 3, 3, 3, 1, 3, 2, 4, 4, 3, 4, 1, 3, 3, 1, 3, 2, 3, 3, 1, 3, 2, 1, 1, 2, 1, 4, 4, 4, 3, 4, 1, 2, 2, 4, 2, 3, 4, 4, 3, 4, 1, 4, 4, 3, 4, 1
Offset: 0
Examples
6! = 720 decimal = 10340 quinary, so a(6) = 4.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
Crossrefs
Programs
-
Maple
f:= proc(n) option remember; local t; t:= n / 5^padic:-ordp(n,5); procname(n-1)*t mod 5 end proc: f(0):= 1: map(f, [$0..100]); # Robert Israel, Jun 27 2025
-
Mathematica
Table[Module[{sp=Split[IntegerDigits[n!,5]]},If[sp[[-1,-1]]==0,sp[[-2, -1]], sp[[-1,-1]]]],{n,0,100}] (* Harvey P. Dale, Oct 26 2016 *)
-
PARI
a(n)={my(v=[1, 1, 2, 1, 4, 4, 4, 3, 4, 1]); if(n==0, 1, lift(prod(k=0, logint(n,5), Mod(v[1 + n\5^k % 10], 5))))} \\ Andrew Howroyd, Sep 27 2024
Formula
a(n) = (n!/A243757(n)) mod 5. - Ridouane Oudra, Sep 27 2024