login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A056051
a(n) = (n-2)! - 1 (mod n).
2
0, 0, 1, 0, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, 0, -1, 0, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, -1, 0, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1
OFFSET
2,1
COMMENTS
(n-2)! - 1 is congruent to 0 iff n is a prime and is congruent to -1 iff n is a composite > 4.
LINKS
MATHEMATICA
Do[m = Mod[(n - 2)! - 1, n]; If[m < 2, Print[m], Print[m - n]], {n, 2, 100}]
PROG
(PARI) A056051(n) = { my(m=(((n-2)!-1)%n)); if(m < 2, m, m-n); }; \\ Antti Karttunen, Sep 14 2017, after Mathematica-code.
CROSSREFS
Cf. A005171.
Sequence in context: A178226 A288622 A095907 * A143541 A359583 A344120
KEYWORD
easy,sign
AUTHOR
Robert G. Wilson v, Jul 25 2000
STATUS
approved