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.

Previous Showing 21-30 of 31 results. Next

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

Original entry on oeis.org

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
Offset: 0

Views

Author

Vladimir Reshetnikov, Nov 24 2010

Keywords

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

Examples

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

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.

Programs

  • Mathematica
    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 *)
  • 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
    
  • Python
    from functools import reduce
    from sympy.ntheory.factor_ import digits
    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<Chai Wah Wu, Dec 07 2023
  • SageMath
    A173670 = lambda n: A008904(10**n)  # D. S. McNeil, Dec 14 2010
    

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)

Extensions

Extended by D. S. McNeil, Dec 12 2010

A073095 Numbers k such that the final nonzero digit of k! is the same as the last digit of binomial(2k,k) (in base 10).

Original entry on oeis.org

5, 12, 26, 31, 35, 51, 56, 60, 136, 152, 157, 177, 182, 252, 257, 275, 280, 287, 300, 305, 312, 627, 632, 650, 655, 662, 675, 680, 687, 751, 756, 760, 786, 811, 886, 902, 907, 927, 932, 1251, 1256, 1260, 1286, 1311, 1377, 1382, 1400, 1405, 1412, 1425
Offset: 1

Views

Author

Benoit Cloitre, Aug 18 2002

Keywords

Examples

			12! = 479001600, binomial(24,12) = 2704156, and the last nonzero digit of 12! is the same as the last digit of binomial(24,12), hence 12 is in the sequence.
		

Programs

  • Mathematica
    Select[Range[1500],Mod[#!/10^IntegerExponent[#!,10],10]==Mod[Binomial[2 #,#],10]&] (* Harvey P. Dale, Sep 13 2022 *)
  • Python
    from math import comb
    from functools import reduce
    from itertools import count, zip_longest, islice
    from sympy.ntheory.factor_ import digits
    from sympy.ntheory.modular import crt
    def A073095_gen(startvalue=2): # generator of terms >= startvalue
        for n in count(max(startvalue,2)):
            s, s2 = digits(n,5)[-1:0:-1], digits(n<<1,5)[-1:0:-1]
            if reduce(lambda x,y:x*y%10,(((6,2,4,8,6,2,4,8,2,4,8,6,6,2,4,8,4,8,6,2)[(a<<2)|(i*a&3)] if i*a else (1,1,2,6,4)[a]) for i, a in enumerate(s)),6)==crt([2,5],[0,reduce(lambda x,y:x*y%5,(comb(a, b) for a, b in zip_longest(s2,s,fillvalue=0)))])[0]:
                yield n
    A073095_list = list(islice(A073095_gen(),50)) # Chai Wah Wu, Dec 07 2023

Formula

k such that A008904(k) = binomial(2k, k) reduced (mod 10).

A116081 Final nonzero digit of n^n.

Original entry on oeis.org

1, 4, 7, 6, 5, 6, 3, 6, 9, 1, 1, 6, 3, 6, 5, 6, 7, 4, 9, 6, 1, 4, 7, 6, 5, 6, 3, 6, 9, 9, 1, 6, 3, 6, 5, 6, 7, 4, 9, 6, 1, 4, 7, 6, 5, 6, 3, 6, 9, 5, 1, 6, 3, 6, 5, 6, 7, 4, 9, 6, 1, 4, 7, 6, 5, 6, 3, 6, 9, 9, 1, 6, 3, 6, 5, 6, 7, 4, 9, 6, 1, 4, 7, 6, 5, 6, 3, 6, 9, 1, 1, 6, 3, 6, 5, 6, 7, 4, 9, 1, 1, 4, 7, 6, 5
Offset: 1

Views

Author

Greg Dresden, Mar 12 2006

Keywords

Comments

The decimal number .147656369116... formed from these digits is a transcendental number; see Dresden's second article. These digits are never eventually periodic.
Digits appear with predictable frequencies: 1/10 for 3, 4, and 7; 1/9 for 5; 3/25 for 9; 28/225 for 1; and 307/900 for 6. - Charles R Greathouse IV, Oct 03 2022

Examples

			a(4) = 6 because 4^4 (which is 256) ends in 6.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local d, m, p; d:= min(padic:-ordp(n,2), padic:-ordp(n,5));
       m:= n/10^d;
       p:= n - 1 mod 4 + 1;
       m &^ p mod 10;
    end proc:
    seq(f(n), n=1..1000); # Robert Israel, Oct 19 2014
  • Mathematica
    f[n_] := Block[{m = n}, While[ Mod[m, 10] == 0, m /= 10]; PowerMod[m, n, 10]]; Array[f, 105] (* Robert G. Wilson v, Mar 13 2006 and modified Oct 12 2014 *)
  • PARI
    f(n) = while(!(n % 10), n/=10); n % 10; \\ A065881
    a(n) = lift(Mod(f(n), 10)^n); \\ Michel Marcus, Sep 13 2022
    
  • PARI
    a(n)=my(k=n/10^valuation(n,10)); lift(Mod(k,10)^(n%4+4)) \\ Charles R Greathouse IV, Sep 13 2022
    
  • Python
    def a(n):
        k = n
        while k%10 == 0: k //= 10
        return pow(k, n, 10)
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Sep 13 2022
    
  • Python
    def A116081(n): return pow(int(str(n).rstrip('0')[-1]),n,10) # Chai Wah Wu, Dec 07 2023

Formula

a(n) = A065881(n)^n mod 10 = A010879(A065881(n)^(A010883(n-1))). - Robert Israel, Oct 19 2014

Extensions

More terms from Robert G. Wilson v, Mar 13 2006

A208279 Central terms of Pascal's triangle mod 10 (A008975).

Original entry on oeis.org

1, 2, 6, 0, 0, 2, 4, 2, 0, 0, 6, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 2, 0, 0, 4, 8, 4, 0, 0, 2, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, 6, 0, 0, 2, 4, 2, 0, 0, 6, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Reinhard Zumkeller, Feb 25 2012

Keywords

Comments

From Chai Wah Wu, Dec 08 2023: (Start)
Last digit of central binomial coefficient binomial(2n,n) in base 10.
A000984 mod 10.
A073095 are numbers n such that a(n) = A008904(n).
a(n) is even for n>0. (End)
From Robert Israel, Dec 08 2023: (Start)
If at least one base-5 digit of n is 3 or 4, then a(n) = 0.
Otherwise, if k 1's occur in the base-5 expansion of n, then a(n) = 2^k (mod 10) if k > 0, or 6 if k = 0. (End)

Crossrefs

Programs

  • Haskell
    a208279 n = a008975 (2*n) n
    
  • Maple
    f:= proc(n) local A,v;
       A:= convert(n,base,5);
       if select(`>=`,A,3) <> [] then return 0 fi;
       v:= numboccur(1,A);
       if v > 0 then 2^v mod 10
       else 6
       fi
    end proc:
    f(0):= 1:
    map(f, [$0..200]); # Robert Israel, Dec 08 2023
  • Mathematica
    Array[Mod[Binomial[2#,#],10]&,100,0] (* Paolo Xausa, Dec 09 2023 *)
  • Python
    from sympy.ntheory.factor_ import digits
    def A208279(n):
        if n == 0: return 1
        s = digits(n,5)[1:]
        return 0 if any(x>2 for x in s) else ((6,2,4,8)[a&3] if (a:=s.count(1)) else 6) # Chai Wah Wu, Dec 08 2023

Formula

a(n) = A008975(2*n,n) = binomial(2n,n) mod 10.

A063944 Final nonzero digit of (n!)! (A000197).

Original entry on oeis.org

1, 1, 2, 2, 6, 6, 6, 4, 6, 8, 2, 8, 8, 6, 4, 4, 6, 6, 8, 2, 6, 4, 4, 8, 2, 2, 6, 2, 2, 6, 4, 6, 2, 2, 8, 4, 6, 8, 2, 2, 2, 2, 8, 6, 6, 6, 2, 2, 6, 8, 4, 2, 2, 2, 8, 8, 4, 4, 2, 6, 8, 6, 4, 6, 6, 4, 8, 2, 2, 4, 4, 2, 8, 2, 8, 2, 4, 2, 8, 8, 6, 8, 2, 8, 4, 4, 6, 8, 8, 6, 2, 4, 6, 2, 6, 4, 2, 6, 4, 6, 2, 6, 4, 2, 8, 2, 4, 2
Offset: 0

Views

Author

Jason Earls, Sep 01 2001

Keywords

Crossrefs

Programs

  • PARI
    for(n=0,22,m=n!!; while(Mod(m,10) == 0,m=m/10); print(Mod(m,10)))
    
  • Python
    from functools import reduce
    from math import prod, factorial
    from sympy.ntheory.factor_ import digits
    def A063944(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(factorial(n),5)[-1:0:-1])))*6%10 if n>1 else 1 # Chai Wah Wu, Dec 07 2023

Extensions

More terms from David W. Wilson, Sep 05 2001, who remarks that "I'll tell you, computing (107!)! took up some disk space!"

A367799 Ordinal transform of the final nonzero digit of the factorial numbers.

Original entry on oeis.org

1, 2, 1, 1, 1, 2, 3, 2, 4, 1, 2, 3, 2, 4, 5, 5, 6, 3, 7, 6, 3, 4, 8, 5, 4, 6, 7, 9, 8, 5, 10, 11, 6, 12, 7, 8, 9, 9, 10, 13, 11, 12, 10, 13, 14, 7, 8, 14, 9, 11, 15, 16, 12, 17, 15, 13, 14, 16, 15, 10, 11, 12, 18, 13, 16, 14, 15, 19, 16, 17, 17, 18, 17, 19, 20
Offset: 0

Views

Author

Alois P. Heinz, Dec 07 2023

Keywords

Comments

n is the a(n)-th nonnegative integer producing value A008904(n).

Examples

			a(11) = 3 because 11! = 39916800 is the third factorial with final nonzero digit 8 after 9! = 362880 and 10! = 3628800. A008904(k) = 8 for k = 9, 10, 11, ... .
		

Crossrefs

Programs

  • Python
    from functools import reduce
    from itertools import count, islice
    from collections import Counter
    from sympy.ntheory.factor_ import digits
    def A367799_gen(): # generator of terms
        c = Counter()
        for n in count(0):
            c[m:=reduce(lambda x,y:x*y%10,(((6,2,4,8,6,2,4,8,2,4,8,6,6,2,4,8,4,8,6,2)[(a<<2)|(i*a&3)] if i*a else (1,1,2,6,4)[a]) for i, a in enumerate(digits(n,5)[-1:0:-1])),6) if n>1 else 1]+=1
            yield c[m]
    A367799_list = list(islice(A367799_gen(),50)) # Chai Wah Wu, Dec 08 2023

Formula

Ordinal transform of A008904.
a(n) = |{ j in {0..n} : A008904(j) = A008904(n) }|.

A056129 Final nonzero digit of n-th primorial.

Original entry on oeis.org

1, 2, 6, 3, 1, 1, 3, 1, 9, 7, 3, 3, 1, 1, 3, 1, 3, 7, 7, 9, 9, 7, 3, 9, 1, 7, 7, 1, 7, 3, 9, 3, 3, 1, 9, 1, 1, 7, 1, 7, 1, 9, 9, 9, 7, 9, 1, 1, 3, 1, 9, 7, 3, 3, 3, 1, 3, 7, 7, 9, 9, 7, 1, 7, 7, 1, 7, 7, 9, 3, 7, 1, 9, 3, 9, 1, 3, 7, 9, 9, 1, 9, 9, 9, 7, 3, 9, 1, 7, 7, 1, 7, 3, 1, 1, 9, 7, 3, 3, 9, 9
Offset: 0

Views

Author

Robert G. Wilson v, Jul 28 2000

Keywords

Comments

For n > 2, a(n) is in {1, 3, 7, 9}.

Crossrefs

Programs

  • Mathematica
    Do[p = Product[Prime[m], {m, 1, n}]; While[Mod[p, 10] == 0, p = p/10]; Print[Mod[p, 10]], {n, 0, 100}]
  • PARI
    a(n)=if(n<3, return([1,2,6][n+1])); my(m=Mod(3,10)); forprime(p=7,prime(n), m*=p); lift(m) \\ Charles R Greathouse IV, Dec 03 2024

Formula

a(n) = prime(n)#/10 mod 10 for n > 2. - Charles R Greathouse IV, Dec 03 2024

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

Original entry on oeis.org

8, 2, 6, 4, 2, 2, 6, 2, 6, 4, 2, 2
Offset: 0

Views

Author

Robert G. Wilson v, Jan 01 2011

Keywords

Comments

It is possible to find a(10) using the program from the second Bomfim link, or a similar GMP program. Reserve 312500001 words instead of 31250001. Use a computer with at least 6 GB of RAM. - Washington Bomfim, Jan 06 2011

Crossrefs

Programs

  • Mathematica
    f[n_] := Mod[6Times @@ (Rest[FoldList[{ 1 + #1[[1]], #2!2^(#1[[1]]#2)} &, {0, 0}, Reverse[IntegerDigits[n, 5]]]]), 10][[2]]; (* Jacob A. Siehler *) Table[ f[10^10^n], {n, 0, 4}]
  • PARI
    \\ L is the list of the N digits of 2^(10^n) in base 5.
    \\ With 2^(10^n) in base 5 as (a_h, ... , a_0)5,
    \\ L[1] = a_0, ... ,L[N] = a_h.
    convert(n)={n=2^(10^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 8"); for(n=1, 5, 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, Jan 06 2011
    
  • Python
    from functools import reduce
    from sympy.ntheory.factor_ import digits
    def A178969(n): return reduce(lambda x,y:x*y%10,(((6,2,4,8,6,2,4,8,2,4,8,6,6,2,4,8,4,8,6,2)[(a<<2)|(i*a&3)] if i*a else (1,1,2,6,4)[a]) for i, a in enumerate(sympydigits(1<<10**n,5)[-1:0:-1])),6) if n else 8 # Chai Wah Wu, Dec 07 2023

Formula

From Washington Bomfim, Jan 06 2011: (Start)
a(n) = A008904(10^(10^n)).
a(n) = A008904(2^(10^n)), if n > 0.
For n >= 1, with N = 10^n, 2^N represented in base 5 as (a_h, ..., 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)

Extensions

a(9) from Washington Bomfim, Jan 06 2011
a(10) from Chai Wah Wu, Dec 07 2023
a(11) from Chai Wah Wu, Dec 08 2023

A113621 Numbers k such that the representation of k^2 is a substring of that of k!, in base 10.

Original entry on oeis.org

1, 20, 29, 170, 176, 241, 3136, 9800, 20309, 20486, 53663, 73793, 94836, 200000
Offset: 1

Views

Author

Giovanni Resta, Jan 26 2006

Keywords

Comments

Using one of the fast algorithms for computing the last nonzero digit of the factorial (A008904) it is easy to see that also 200000000 and 2*10^16 are terms.

Examples

			29^2 = 841 and 29! = 8(841)761993739701954543616000000.
		

Crossrefs

Programs

  • Mathematica
    lst={}; Do[If[{}!= StringPosition[ToString[n! ], ToString[n^2]], AppendTo[lst, n]], {n, 10000}]; lst

Extensions

Extended by Giovanni Resta, Apr 04 2014

A176786 Last nonzero digit of A000043(n)!.

Original entry on oeis.org

6, 4, 8, 6, 8, 6, 6, 8, 2, 6, 4, 4, 8, 8, 6, 2, 4, 2, 2, 2, 8, 2, 6, 2, 4, 4, 8, 6, 4, 2, 8, 6, 2, 6, 2, 8, 2, 6, 2, 8, 4, 6, 2, 8, 8, 8, 2, 8
Offset: 1

Views

Author

Washington Bomfim, Dec 07 2010

Keywords

Comments

The C program, from first link, is based on a new method, see second link. It was developed from a congruence found in the first reference "Concrete Mathematics". The function D() of this program implements the simple division algorithm found in "D. E. Knuth, The Art of Computer Programming, V.2." (second reference). Another approach can be to use Dresden's formula that can be found from the third link. One can use the function LastDigit() of the mentioned program to find the last nonzero digit of N! for very large values of N. The factorial of the 47th (known) Mersenne prime has approximately 10^12,978,195 digits.
Many other algorithms for the general problem of finding the last nonzero digit of a factorial are given in A008904. [D. S. McNeil, Dec 10 2010]

Examples

			a(1) = 6 since the first Mersenne prime is 3, and 3! = 6.
		

References

  • Ronald L. Graham, Donald E. Knuth and Oren Patashnik, Concrete Math.; Addison-Wesley, section 4, exercises 40, and 54.
  • D. E. Knuth, The Art of Computer Programming, vol.2, section 4.3.1, exercise 16.

Crossrefs

Formula

a(n) = A008904(2^A000043(n)-1) = A008904(A000668(n)).

Extensions

Terms for n <= 40 confirmed by D. S. McNeil, Dec 08 2010
a(41)-a(47) from Max Alekseyev, Jan 31 2012, Mar 16 2015, Dec 01 2019
a(48) from Chai Wah Wu, Dec 07 2023
Previous Showing 21-30 of 31 results. Next