Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

For a prime p=4k+1p=4k+1p=4k+1, the numbers x=±(2k)!x=\pm(2k)!x=±(2k)! solve x2+1≡0(modp)x^2+1\equiv 0 \pmod px2+1≡0(modp)

Proved
AlfutovaUstinov.problem_4_128

by evgeth · Sep 28, 2026 · Mathlib 0df444a (Lean v4.33.1)

elementary-number-theorynumber-theoryquadratic-residueswilson-theorem

This is Problem 4.128 of N. B. Alfutova and A. V. Ustinov, Algebra and Number Theory (MCCME, 2002), Chapter 4, §4 “Theorems of Fermat and Euler”.

Theorem. Let ppp be a prime of the form p=4k+1p=4k+1p=4k+1 with k∈Nk\in\mathbb Nk∈N. Then both numbers x=(2k)!x=(2k)!x=(2k)! and x=−(2k)!x=-(2k)!x=−(2k)! are solutions of the congruence

x2+1≡0(modp).x^{2}+1\equiv 0 \pmod p .x2+1≡0(modp).

This gives an explicit square root of −1-1−1 modulo every prime p≡1(mod4)p\equiv 1 \pmod 4p≡1(mod4), complementing Problem 4.126, which shows that no such square root exists for primes p≡3(mod4)p\equiv 3 \pmod 4p≡3(mod4). It is a consequence of Wilson's theorem.

Formalization Note The factorial is Nat.factorial, cast to Z\mathbb ZZ; the two claims (for +(2k)!+(2k)!+(2k)! and −(2k)!-(2k)!−(2k)!) are stated separately as congruences in Z\mathbb ZZ (Int.ModEq).

Preamble
import Mathlib
Formal statement
namespace AlfutovaUstinov

theorem problem_4_128 (p k : ℕ) (hp : p.Prime) (hpk : p = 4 * k + 1) :
    (Nat.factorial (2 * k) : ℤ) ^ 2 + 1 ≡ 0 [ZMOD p] ∧
      (-(Nat.factorial (2 * k) : ℤ)) ^ 2 + 1 ≡ 0 [ZMOD p] := by sorry

end AlfutovaUstinov
Source
N. B. Alfutova, A. V. Ustinov, «Алгебра и теория чисел. Сборник задач для математических школ» (Algebra and Number Theory: a problem book for mathematical schools), Moscow: MCCME, 2002, Chapter 4 «Арифметика остатков» (Arithmetic of residues), §4 «Теоремы Ферма и Эйлера» (Theorems of Fermat and Euler), Problem 4.128. Problem text and answer as catalogued on problems.ru, problem 60754: https://problems.ru/view_problem_details_new.php?id=60754

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me