A374015 Residue modulo 5 of n! divided by the highest power of 10 which divides n!.
1, 1, 2, 1, 4, 2, 2, 4, 2, 3, 3, 3, 1, 3, 2, 3, 3, 1, 3, 2, 4, 4, 3, 4, 1, 4, 4, 3, 4, 1, 3, 3, 1, 3, 2, 2, 2, 4, 2, 3, 2, 2, 4, 2, 3, 1, 1, 2, 1, 4, 2, 2, 4, 2, 3, 4, 4, 3, 4, 1, 1, 1, 2, 1, 4, 1, 1, 2, 1, 4, 3, 3, 1, 3, 2, 4, 4, 3, 4, 1, 3, 3, 1, 3, 2, 2, 2, 4, 2, 3, 2, 2, 4, 2, 3, 1, 1, 2, 1, 4, 4, 4, 3, 4, 1, 3
Offset: 0
Examples
a(5) = 1*2*3*4*5/10 mod 5 = 2.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..20000
Programs
-
Maple
a:= n-> (f-> irem(f/10^padic[ordp](f, 10), 5))(n!): seq(a(n), n=0..105); # Alois P. Heinz, Jun 25 2024
-
Mathematica
a[n_]:=Mod[n!/10^IntegerExponent[n!, 10],5]; Array[a,106,0] (* Stefano Spezia, Jun 25 2024 *)
-
PARI
a(n)=if(n>4, my(k=n\5); return(lift((n%5)!*a(k)*Mod(2,5)^k))); n!%5 \\ Charles R Greathouse IV, Jan 24 2025
-
Python
v=[[((1,1,2,1,4)[j]*2**(i*j))%5 for j in range(5)] for i in range(4)] def a(n): c,p=0,1 while n: c,n,p=(c+1)%4,n//5,(v[c][n%5]*p)%5 return(p) # Cezary Glowacz, Feb 05 2025
Comments