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.

A166862 Primes p that divide n! + 1 for some n other than p-1.

This page as a plain text file.
%I A166862 #12 Feb 16 2025 08:33:11
%S A166862 2,7,11,19,23,29,43,47,59,61,67,71,79,83,103,109,127,131,137,139,149,
%T A166862 163,179,191,193,199,227,233,239,251,257,263,269,271,277,293,307,311,
%U A166862 317,347,359,367,379,383,389,397,401,419,431,443,449,461,463,467,479
%N A166862 Primes p that divide n! + 1 for some n other than p-1.
%C A166862 For n >= p, p is one of the factors of n!, so p cannot divide n! + 1. As a result, only 0 <= n <= p-2 needs to be searched.
%C A166862 For n = p-1, by Wilson's Theorem, (p-1)! = -1 (mod p), so p divides (p-1)! + 1.
%C A166862 Since by convention 0! = 1, 2 is included in the sequence as dividing 0!+1 = 2.
%C A166862 The standard heuristic suggests that the fraction of primes in this sequence is 1 - 1/e or about 63%. - _Charles R Greathouse IV_, Apr 17 2013
%H A166862 Charles R Greathouse IV, <a href="/A166862/b166862.txt">Table of n, a(n) for n = 1..10000</a>
%H A166862 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/WilsonsTheorem.html">Wilson's Theorem</a>
%e A166862 11 is included in the sequence since 11 divides 5! + 1 = 121.
%e A166862 13 is not included in the sequence since the only n for which 13 divides n! + 1 is n = 12.
%o A166862 (PARI) isA166862(n) = {local(r);r=0;for(i=0,n-2,if((i!+1)%n==0,r=1));r}
%o A166862 (PARI) is(p)=my(m=Mod(1,p)); for(k=2,p-2,m*=k; if(m==-1, return(isprime(p)))); p==2 \\ _Charles R Greathouse IV_, Apr 17 2013
%Y A166862 Cf. A000142, A038507, A051301, A002583.
%K A166862 nonn
%O A166862 1,1
%A A166862 _Michael B. Porter_, Oct 22 2009