login
Remainder when (n-1)! + 1 is divided by n.
6

%I #14 Feb 19 2024 10:28:12

%S 0,0,0,3,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,

%T 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,

%U 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,1,1,1,0,1,1,1

%N Remainder when (n-1)! + 1 is divided by n.

%C Related to Wilson's theorem. a(n) = 0 iff n = 1 or a prime; a(n) = 1 iff n > 4 is composite; a(n) = 3 iff n = 4.

%D Albert H. Beiler, Recreations in The Theory of Numbers, The Queen of Mathematics Entertains, Second Edition, Dover Publications, Inc., New York, 1966, Page 50.

%H Antti Karttunen, <a href="/A055976/b055976.txt">Table of n, a(n) for n = 1..10000</a>

%t Do[Print[Mod[(n-1)!+1, n]], {n, 1, 100}]

%o (PARI) A055976(n) = (((n-1)!+1)%n); \\ _Antti Karttunen_, Aug 27 2017

%Y Cf. A061007.

%K easy,nonn

%O 1,4

%A _Robert G. Wilson v_, Jul 23 2000