A061006 a(n) = (n-1)! mod n.
0, 1, 2, 2, 4, 0, 6, 0, 0, 0, 10, 0, 12, 0, 0, 0, 16, 0, 18, 0, 0, 0, 22, 0, 0, 0, 0, 0, 28, 0, 30, 0, 0, 0, 0, 0, 36, 0, 0, 0, 40, 0, 42, 0, 0, 0, 46, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 58, 0, 60, 0, 0, 0, 0, 0, 66, 0, 0, 0, 70, 0, 72, 0, 0, 0, 0, 0, 78, 0, 0, 0, 82, 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, 0
Offset: 1
Examples
a(4) = 2 since (4-1)! = 6 = 2 mod 4. a(5) = 4 since (5-1)! = 24 = 4 mod 5. a(6) = 0 since (6-1)! = 120 = 0 mod 6.
Links
- Seiichi Manyama, Table of n, a(n) for n = 1..1000
- Wikipedia, Wilson's theorem
Crossrefs
Programs
-
Mathematica
Table[Mod[(n - 1)!, n], {n, 100}] (* Alonso del Arte, Feb 16 2014 *)
-
PARI
a(n)=if(isprime(n),n-1,if(n==4,2,0)) \\ Charles R Greathouse IV, Mar 31 2014
Comments