The Lagrange path 

 

 

 

Lagrange proved Wilson's theorem, and extended it as follows:



Lagrange's theorem (1777)
.
 

 

 

 

 

 

 

 

Here I show the behaviour of  factorial(`+`(`*`(`/`(1, 2), `*`({`+`(p, `-`(1))})))) (mod p) for all odd primes up to  

 

 

> L := []: for p from 5 by 4 to 200 do if isprime(p) then

            R2||p := PRFAC(1, (p-1)/2, p, 1):

          
### COMPUTING THE HALF-FACTORIAL RESIDUE

                L := [op(L), p]: fi od:

print(``); print(array([

['p', ``, ``, '({p-1}/2)!', ``, ``, '({p-1}/2)!^2'],

seq([p, ``, ``, R2||p, ``, ``, mods(R2||p^2, p)],

          
### NOTICE THE SQUARE OF THE HALF-FACTORIAL RESIDUE

p = L)])): print(``);

lprint(`The final two columns show LEAST ABSOLUTE residues mod p.`);
 

 

 

 

array( 1 .. 22, 1 .. 7, [( 3, 7 ) = (-1), ( 14, 2 ) = (``), ( 16, 1 ) = (137), ( 4, 6 ) = (``), ( 17, 2 ) = (``), ( 16, 7 ) = (-1), ( 2, 2 ) = (``), ( 14, 3 ) = (``), ( 3, 1 ) = (13), ( 7, 3 ) = (``),...
`The final two columns show LEAST ABSOLUTE residues mod p.`
 

>
 

> L := []: for p from 5 by 4 to 250 do if isprime(p) then

                    R4||p := PRFAC(1, (p-1)/4, p, 1):

                        L := [op(L), p]: fi od:

print(``); print(array([

['p', ``, ``, '({p-1}/4)!', ``, ``, '({p-1}/4)!^2', ``, ``, '({p-1}/4)!^4'],

seq([p, ``, ``, R4||p, ``, ``, mods(R4||p^2, p), ``, ``, mods(R4||p^4, p)], p = L)])):

print(``); lprint(`The final three columns show LEAST ABSOLUTE residues mod p.`);
 

 

 

 

array( 1 .. 25, 1 .. 10, [( 3, 7 ) = (-3), ( 14, 2 ) = (``), ( 16, 1 ) = (137), ( 22, 10 ) = (49), ( 4, 6 ) = (``), ( 17, 2 ) = (``), ( 5, 10 ) = (-9), ( 16, 7 ) = (17), ( 23, 6 ) = (``), ( 2, 2 ) = (...
`The final three columns show LEAST ABSOLUTE residues mod p.`
 

>
 

> L := []: for p from 5 by 4 to 250 do if isprime(p) then

                    R4||p := PRFAC(1, (p-1)/4, p, 1):

                        L := [op(L), p]: fi od:

print(``); print(array([['p', ``, ``, '({p-1}/4)!^8'],

         seq([p, ``, ``, mods(R4||p^8, p)],
### NOTICE THE 8-TH POWER

p = L)])):

print(``); lprint(`The final column show LEAST ABSOLUTE residues mod p,`);
print(``); lprint(`and take note of those TWO -1 residues at p = 17 and 241.,`);
 

 

 

 

 

 

array( 1 .. 25, 1 .. 4, [( 7, 3 ) = (``), ( 25, 3 ) = (``), ( 19, 4 ) = (-25), ( 6, 4 ) = (7), ( 22, 1 ) = (197), ( 20, 3 ) = (``), ( 9, 1 ) = (61), ( 21, 2 ) = (``), ( 16, 1 ) = (137), ( 17, 2 ) = (`...
`The final column show LEAST ABSOLUTE residues mod p,`
`and take note of those TWO -1 residues at p = 17 and 241.,`
 

>
 

>