cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A173670 Last nonzero decimal digit of (10^n)!.

This page as a plain text file.
%I A173670 #63 Jun 11 2025 04:00:35
%S A173670 1,8,4,2,8,6,4,8,6,4,2,8,6,6,6,6,8,2,6,8,8,2,4,2,2,8,2,6,2,6,4,4,6,6,
%T A173670 4,2,8,2,6,4,6,4,2,4,4,2,8,8,4,4,2,6,6,4,4,8,8,4,6,2,2,4,4,2,4,6,2,4,
%U A173670 4,4,2,2,6,8,6,6,4,2,2,4,4,2,8,8,2,6,2,6,2,2,6,2,2,8,6,2,2,4,6,6
%N A173670 Last nonzero decimal digit of (10^n)!.
%C A173670 Except for n = 1, a(n) is also the last nonzero digit of (2^n)!. See the third Bomfim link. - _Washington Bomfim_, Jan 04 2011
%H A173670 Washington Bomfim, <a href="/A173670/b173670.txt">Table of n, a(n) for n = 0..1000</a>
%H A173670 Washington Bomfim, <a href="http://oeis.org/w/images/4/48/AlgLastFinal1.txt">An algorithm to find the last nonzero digit of n!</a>.
%H A173670 Washington Bomfim, <a href="http://oeis.org/w/images/6/61/Proof3.txt">A property of the last non-zero digit of factorials</a>.
%F A173670 From _Washington Bomfim_, Jan 04 2011: (Start)
%F A173670 a(n) = A008904(10^n).
%F A173670 a(0) = 1, a(1) = 8, if n >= 2, with
%F A173670 2^n represented in base 5 as (a_h, ..., a_1, a_0)_5,
%F A173670 t = Sum_{i = h, h-1, ..., 0} (a_i even),
%F A173670 x = Sum_{i = h, h-1, ..., 1} (Sum_{k = h, h-1, ..., i} (a_i)),
%F A173670 z = (x + t/2) mod 4, and y = 2^z,
%F A173670 a(n) = 6*(y mod 2) + y*(1 -( y mod 2)). (End)
%e A173670 a(1) = 8, because (10^1)! = 3628800.
%t A173670 f[n_] := If[n > 1, Mod[6Times @@ (Rest[FoldList[{ 1 + #1[[1]], #2!2^(#1[[1]]#2)} &, {0, 0}, Reverse[IntegerDigits[n, 5]]]]), 10][[2]], 1]; Table[ f[10^n], {n, 0, 104}] (* _Jacob A. Siehler_ *)
%o A173670 (SageMath) A173670 = lambda n: A008904(10**n)  # _D. S. McNeil_, Dec 14 2010
%o A173670 (PARI)
%o A173670 \\ L is the list of the N digits of 2^n in base 5.
%o A173670 \\ L[1] = a_0 ,..., L[N] = a_(N-1).
%o A173670 convert(n)={n=2^n; x=n; N=floor(log(n)/log(5)) + 1;
%o A173670   L = listcreate(N);
%o A173670   while(x, n=floor(n/5); r=x-5*n; listput(L, r); x=n;);
%o A173670   L; N
%o A173670 };
%o A173670 print("0 1");print("1 8");for(n=2,1000,print1(n," "); convert(n); q=0;t=0;x=0;forstep(i=N,2,-1,a_i=L[i];q+=a_i;x+=q;t+=a_i*(1-a_i%2););a_i=L[1];t+=a_i*(1-a_i%2);z=(x+t/2)%4;y=2^z;an=6*(y%2)+y*(1-(y%2)); print(an)); \\ _Washington Bomfim_, Dec 31 2010
%o A173670 (Python)
%o A173670 from functools import reduce
%o A173670 from sympy.ntheory.factor_ import digits
%o A173670 def A173670(n): return reduce(lambda x,y:x*y%10,((1,1,2,6,4)[a]*((6,2,4,8)[i*a&3] if i*a else 1) for i, a in enumerate(digits(1<<n,5)[-1:0:-1],n)))*6%10 if n else 1 # _Chai Wah Wu_, Dec 07 2023
%Y A173670 Cf. A008904, final nonzero digit of n!.
%Y A173670 Cf. A055476, Powers of ten written in base 5.
%Y A173670 Cf. A053824, Sum of digits of n written in base 5.
%K A173670 nonn,easy,base
%O A173670 0,2
%A A173670 _Vladimir Reshetnikov_, Nov 24 2010
%E A173670 Extended by _D. S. McNeil_, Dec 12 2010