OFFSET
1,3
COMMENTS
It appears that a(n) = (n!*h(n)) mod n, where h(n) = Sum_{k = 1..n} 1/k. - Gary Detlefs, Sep 04 2010
Indeed: It is easy to show n!*h(n) - (n-1)! = n*(n-1)!*h(n-1). Since (n-1)!*h(n-1) is integral, n!*h(n) == (n-1)! mod n. - Franz Vrabec, Apr 08 2017
LINKS
Seiichi Manyama, Table of n, a(n) for n = 1..1000
Wikipedia, Wilson's theorem
FORMULA
EXAMPLE
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.
MATHEMATICA
Table[Mod[(n - 1)!, n], {n, 100}] (* Alonso del Arte, Feb 16 2014 *)
PROG
(PARI) a(n)=if(isprime(n), n-1, if(n==4, 2, 0)) \\ Charles R Greathouse IV, Mar 31 2014
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Henry Bottomley, Apr 12 2001
STATUS
approved