HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /Prove that if p is a prime with p ≡ 1 pmod 4, then x = ((p - 1)/2)! …
AdvancedMathematicsHigh School (11–12)Number TheoryproofNumericalOlympiad

Prove that if p is a prime with p ≡ 1 pmod 4, then x = ((p - 1)/2)! …

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

Prove that if ppp is a prime with p≡1(mod4)p \equiv 1 \pmod 4p≡1(mod4), then x=(p−12)!x = \left(\tfrac{p - 1}{2}\right)!x=(2p−1​)! satisfies x2≡−1(modp)x^2 \equiv -1 \pmod px2≡−1(modp). Pair each factor kkk of (p−1)!(p - 1)!(p−1)! with p−kp - kp−k and use Wilson's theorem. Then apply it to p=29p = 29p=29. Find the remainder of 14!14!14! on division by 292929 and the other solution of x2≡−1(mod29)x^2 \equiv -1 \pmod{29}x2≡−1(mod29) between 111 and 282828.

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

Wilson: (p−1)!≡−1(modp)(p - 1)! \equiv -1 \pmod p(p−1)!≡−1(modp) for a prime ppp. The order ord⁡n(a)\operatorname{ord}_n(a)ordn​(a), the least kkk with ak≡1a^k \equiv 1ak≡1, divides every mmm with am≡1a^m \equiv 1am≡1, so it divides φ(n)\varphi(n)φ(n):

am≡1(modn)  ⟺  ord⁡n(a)∣m.\displaystyle a^m \equiv 1 \pmod n \iff \operatorname{ord}_n(a) \mid m.am≡1(modn)⟺ordn​(a)∣m.

The worked solution

Check an answer or open a hint to unlock the worked solution.

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Step 1. Pair the factors. (p−1)!=∏k=1(p−1)/2k(p−k)≡∏k=1(p−1)/2(−k2)=(−1)(p−1)/2[(p−12)!]2(p - 1)! = \prod_{k=1}^{(p-1)/2} k(p - k) \equiv \prod_{k=1}^{(p-1)/2} (-k^2) = (-1)^{(p-1)/2}\left[\left(\tfrac{p - 1}{2}\right)!\right]^2(p−1)!=∏k=1(p−1)/2​k(p−k)≡∏k=1(p−1)/2​(−k2)=(−1)(p−1)/2[(2p−1​)!]2.

Step 2. The sign. If p≡1(mod4)p \equiv 1 \pmod 4p≡1(mod4), then p−12\tfrac{p - 1}{2}2p−1​ is even, and the sign is +++.

Step 3. Wilson. (p−1)!≡−1(p - 1)! \equiv -1(p−1)!≡−1, so x2≡−1x^2 \equiv -1x2≡−1 with x=(p−12)!x = \left(\tfrac{p - 1}{2}\right)!x=(2p−1​)!. Proof complete.

Step 4. For p=29p = 29p=29. x=14!x = 14!x=14!. Reduce step by step modulo 292929: 5!=4×29+4≡45! = 4 \times 29 + 4 \equiv 45!=4×29+4≡4, then ×6→24\times 6 \to 24×6→24, ×7=168≡23\times 7 = 168 \equiv 23×7=168≡23, ×8=184≡10\times 8 = 184 \equiv 10×8=184≡10, ×9=90≡3\times 9 = 90 \equiv 3×9=90≡3, ×10→30≡1\times 10 \to 30 \equiv 1×10→30≡1, ×11→11\times 11 \to 11×11→11, ×12=132≡16\times 12 = 132 \equiv 16×12=132≡16, ×13=208≡5\times 13 = 208 \equiv 5×13=208≡5, ×14=70≡12\times 14 = 70 \equiv 12×14=70≡12.

Step 5. Check. 122=144=5×29−1≡−112^2 = 144 = 5 \times 29 - 1 \equiv -1122=144=5×29−1≡−1. The other solution is 29−12=1729 - 12 = 1729−12=17.

Answer: 14!≡12(mod29)14! \equiv 12 \pmod{29}14!≡12(mod29), and the other solution is 171717.

Log in to save this for later
← All Problems
← The decimal of 1/41 repeats, and so does the decimal of 1/17…A vending machine takes tokens worth 7 units and 11 units and gives no change… →
More onNumber Theory

Discussion (0)

Log in to join the discussion.

Loading…

More on this topic

  1. The triangular numbers are 1, 3, 6, 10, …, where the nth one is (n(n + 1))/2…Advanced
  2. Prove that the equation x³ + y³ + z³ = n has no solution in integers when n leaves remainder 4 or 5…Advanced
  3. Find every triple of positive integers a ≤ b ≤ c with 1/a + 1/b + 1/c = 1, and prove that there are…Advanced
  4. Find all pairs of positive integers (x, y) with x² - y² = 945…Hard
  5. A teacher wants a list of every primitive Pythagorean triple whose hypotenuse is less than 100…Advanced
All problems on this topic →