login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A173670 Last nonzero decimal digit of (10^n)!. 5
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,2

COMMENTS

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

LINKS

Table of n, a(n) for n=0..99.

W. Bomfim, Table of n, a(n) for n = 0..1000

W. Bomfim, An algorithm to find the last nonzero digit of n!

W. Bomfim, A property of the last non-zero digit of factorials

FORMULA

From Washington Bomfim, Jan 04 2011: (Start)

a(n) = A008904(10^n).

a(0) = 1, a(1) = 8, if n >= 2, with

2^n represented in base 5 as (a_h, ... ,a_1,a_0)5,

t = sum{i = h, h-1, ... , 0} (a_i even),

x = sum{i=h, h-1, ... , 1}(sum{k=h, h-1, ... , i}(a_i)),

z = (x + t/2) mod 4, and y = 2^z,

a(n) = 6(y mod 2) + y(1-(y mod 2)).

(End)

EXAMPLE

a(1) = 8, because (10^1)! = 3628800

MATHEMATICA

f[n_] := Mod[6Times @@ (Rest[FoldList[{ 1 + #1[[1]], #2!2^(#1[[1]]#2)} &, {0, 0}, Reverse[IntegerDigits[n, 5]]]]), 10][[2]]; f[0] = 1; Table[ f[10^n], {n, 0, 104}]] (* program contributed by Jacob A. Siehler *)

PROG

(Sage) A173670 = lambda n: A008904(10**n)  # D. S. McNeil, Dec 14 2010

(PARI)\\ L is the list of the N digits of 2^n in base 5. \\     L[1] = a_0 , ..., L[N] = a_(N-1).

convert(n)={n=2^n; x=n; N=floor(log(n)/log(5)) + 1;

  L = listcreate(N);

while(x, n=floor(n/5); r=x-5*n; listput(L, r); x=n; );

L; N

};

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

CROSSREFS

Cf. A008904, final nonzero digit of n!.

Cf. A055476, Powers of ten written in base 5.

Cf. A053824, Sum of digits of n written in base 5.

Sequence in context: A014391 A099286 A089729 * A050135 A109595 A256782

Adjacent sequences:  A173667 A173668 A173669 * A173671 A173672 A173673

KEYWORD

nonn,easy,base

AUTHOR

Vladimir Reshetnikov, Nov 24 2010

EXTENSIONS

Extended by D. S. McNeil, Dec 12 2010

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified March 29 03:29 EDT 2017. Contains 284250 sequences.