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.

Showing 1-5 of 5 results.

A062170 Maximum value of factorials mod n.

Original entry on oeis.org

0, 1, 2, 2, 4, 2, 6, 6, 6, 6, 10, 6, 12, 10, 9, 8, 16, 12, 18, 6, 15, 16, 22, 6, 24, 24, 24, 24, 28, 24, 30, 24, 27, 32, 24, 24, 36, 36, 33, 24, 40, 36, 42, 32, 30, 44, 46, 24, 42, 40, 48, 48, 52, 36, 45, 48, 54, 52, 58, 24, 60, 60, 57, 56, 55, 60, 66, 64, 60, 50
Offset: 1

Views

Author

Henry Bottomley, Jun 11 2001

Keywords

Examples

			a(15)=9 since factorials are 1, 2, 6, 24, 120, 720, etc. which mod 15 are 1, 2, 6, 9, 0, 0, etc. and the greatest value is 9.
		

Crossrefs

Cf. A062169.

Programs

  • Mathematica
    With[{fctrls=Factorial[Range[100]]}, Table[Max[Mod[Take[fctrls,n], n]], {n,100}]] (* Harvey P. Dale, Jan 03 2011 *)

A038203 Number of distinct values of factorials mod n.

Original entry on oeis.org

1, 2, 3, 3, 4, 3, 5, 4, 5, 5, 6, 4, 10, 6, 5, 5, 12, 5, 12, 5, 6, 7, 17, 4, 8, 11, 8, 7, 19, 5, 21, 6, 8, 13, 7, 6, 26, 13, 11, 5, 29, 6, 26, 8, 6, 18, 31, 5, 11, 8, 13, 12, 35, 8, 9, 7, 14, 20, 37, 5, 41, 22, 7, 8, 13, 8, 42, 14, 18, 7, 39, 6, 44, 27, 8, 15, 11, 11, 49, 6, 9, 30, 55, 7
Offset: 1

Views

Author

Keywords

Comments

Assuming k! mod n is uniformly distributed mod n up to k = A002034(n), the first k! == 0 (mod n). This gives a(n) ~= (1-(1-1/n)^k)*n, which empirically appears to be a good estimate. For prime p, A002034(p) = p, so we would expect a(p) ~= (1-(1-1/p)^p)*p ~= (1-1/e)*p = 0.63212 p for large primes p. - David W. Wilson, Aug 01 2016

Examples

			a(15)=5 since factorials are 1, 2, 6, 24, 120, etc. which mod 15 are 1, 2, 6, 9, 0, etc. and so there are 5 distinct values.
		

Crossrefs

Programs

  • Mathematica
    nn=90;With[{frls=Range[nn]!},Table[Length[Union[Mod[#,n]&/@frls]],{n,nn}]] (* Harvey P. Dale, Oct 05 2011 *)
  • PARI
    a(n)=my(t=1); #Set(vector(n,k,t=t*k%n)) \\ Charles R Greathouse IV, Aug 03 2016

A086330 a(n) = Sum_{m >= 2} m! mod n.

Original entry on oeis.org

0, 2, 4, 7, 2, 18, 8, 17, 12, 43, 8, 73, 32, 17, 24, 113, 26, 159, 12, 32, 76, 203, 8, 112, 164, 89, 60, 334, 32, 496, 88, 164, 232, 67, 44, 706, 292, 164, 32, 863, 74, 874, 164, 62, 456, 1097, 56, 291, 162, 317, 268, 1124, 116, 142, 88, 425, 566, 1560, 32, 2033, 930
Offset: 2

Views

Author

Walter Carlini, Aug 31 2003

Keywords

Comments

A discrete infinite sum that has some rough analogies to the infinite series for exponentials.

Examples

			a(7) = 2! mod 7 + 3! mod 7 + 4! mod 7 + 5! mod 7 + 6! mod 7 + 7! mod 7 + 8! mod 7 + . . . = 2 mod 7 + 6 mod 7 + 24 mod 7 + 120 mod 7 + 720 mod 7 + 5040 mod 7 + 40320 mod 7 + ... = 2 + 6 + 3 + 1 + 6 + (all further values are zero) = 18.
		

Crossrefs

Cf. A062169.

Programs

  • PARI
    a(n) = sum(m=2, n, m! % n) \\ Michel Marcus, Jul 23 2013
    
  • Python
    def A086330(n):
        a, c = 0, 1
        for m in range(2,n):
            c = c*m%n
            if c==0:
                break
            a += c
        return a # Chai Wah Wu, Apr 16 2024

Formula

a(n) = -1 + Sum_{k=1..n} A062169(n, k). - Vladeta Jovovic, Sep 06 2003

Extensions

Corrected and extended by Vladeta Jovovic, Sep 06 2003

A238532 Number of distinct factorial numbers congruent to -1 (mod n).

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 2, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 1, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0, 0, 3, 0, 0, 0, 7, 0, 1, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

R. J. Mathar, Apr 02 2014

Keywords

Comments

Number of solutions to k! == -1 (mod n), k>=1.
Counts the frequency of the value n-1 in the n-th row of triangle A062169.
Values 1..9 occur for the first time at n = 2, 7, 23, 59, 227, 401, 71, 3643, 62939, which are all prime numbers (see also A230315). Sequence A256519 gives composite k for which a(k) > 0. - Antti Karttunen, May 24 2021

Examples

			There are two 6's in the 7th row of A062169. Therefore a(7)=2.
		

Crossrefs

Programs

  • Maple
    A238532 := proc(n)
        local a,k ;
        a := 0 ;
        for k from 1 to n-1 do
            if modp(k!,n) = modp(-1,n) then
                a := a+1 ;
            end if;
        end do:
        a ;
    end proc: # R. J. Mathar, Apr 02 2014
  • PARI
    A238532(n) = { my(m=1,s=0); for(k=1,oo,m *= k; if(!(m%n),return(s), if(1+(m%n)==n, s++))); }; \\ Antti Karttunen, May 24 2021
    
  • PARI
    A238532(n) = { my(m=Mod(1,n),s=0,x); for(k=1,oo, m *= Mod(k,n); x = lift(m); if(!x,return(s), if(x==(n-1), s++))); }; \\ (Much faster than above program) - Antti Karttunen, May 24 2021

A212320 Irregular triangle: T(n, k) = k! modulo prime(n), 1

Original entry on oeis.org

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

Views

Author

Michel Marcus, Oct 25 2013

Keywords

Comments

It is conjectured that only first and second row have all terms distinct.
This holds for n less than ten million. In Trudgian's terminology, there are no socialist primes less than 10^7. - Charles R Greathouse IV, Nov 05 2013

Examples

			Irregular triangle begins:
  2;
  2, 1, 4;
  2, 6, 3,  1, 6;
  2, 6, 2, 10, 5, 2, 5, 1, 10;
		

Crossrefs

Cf. A062169.

Programs

  • Mathematica
    row[n_] := With[{p = Prime[n]}, Mod[Range[2, p-1]!, p]]; Table[row[n], {n, 2, 9}] // Flatten (* Jean-François Alcover, Oct 25 2013 *)
  • PARI
    row(n) = {p = prime(n); for (i = 2, p-1, print1(i! % p, ", ");); print();}
Showing 1-5 of 5 results.