Modular arithmetic and factorials

In summary, the conversation discusses three problems related to modular arithmetic. The first one involves proving a statement about odd integers and their modular inverses. The second problem is to find the solutions of a congruence equation. The third problem asks for a simple formula for finding the remainder of a factorial when divided by a prime number. Through the conversation, the concept of modular inverses and their properties are explored and used to solve the problems. The conclusion is that for any odd prime number, the product of all integers from 1 to that prime number, when divided by the prime itself, always leaves a remainder of -1 ($p-1$) modulo $p$.
  • #1
Ciaran
72
0
Hi there, I actually have a few questions I came across on my studies. They are
(a) Show that if p is odd and x is an integer such that x^2 ≡ 1 mod p^k, then x = ±1 mod p^k
(b) Find the solutions of the congruence equation x^2 ≡ 1 mod 2^k
(c) What is the remainder of (p − 1)!, when divided by p? In other words: find a simple
formula for (p − 1)! ∈ Zp.

I'm really not sure how to start a and b off, but for c I've been trying it with small examples, looking for a pattern.

Any help would be appreciated!
 
Mathematics news on Phys.org
  • #2
For (a) and (b), try rewriting it as $x^2 - 1 \equiv 0 \pmod{p^k}$ and factor the LHS - what does that imply? For (c), think about what $(p - 1)!$ means: you're taking the product of all the integers from $1$ to $p - 1$. Think about modular inverses!
 
  • #3
Thanks for your reply- I did factor the LHS and got (x+1)(x-1) and concluded that p cannot divide both factors? Not sure about the next step. For c, I thought making (p-1)! congruent to x mod p then multiplying through by p would work but I've ended up with 0 mod p= xp.
 
  • #4
Ah, I have now solved a and b! But I am still not sure about c.
 
  • #5
Ciaran said:
Ah, I have now solved a and b! But I am still not sure about c.

Good job! For (c), consider that $x^2 \equiv 1 \pmod{p}$ if and only if $x$ is equal to its own modular inverse (e.g. divide through by $x$ to see that). That means that modulo $p$, only $1$ and $-1$ (which is equivalent to $p - 1$ modulo $p$) are their own inverses, and consequently you can partition the integers between $2$ and $p - 2$ into pairs of distinct modular inverses, and therefore... :p
 
Last edited:
  • #6
Therefore the product 2x3... p-2 = p-2 ! is made up of these pairs?
 
  • #7
Yes, and since multiplication is commutative and each pair multiplies to 1 (since each integer in the pair is the inverse of the other) what does that tell you about the product $2 \times 3 \times \cdots \times (p - 2)$ modulo $p$? Perhaps more clearly, rearrange the product so that the pairs of inverses appear consecutively, what do you see?

Oh by the way I notice you didn't actually specify, $p$ is an odd prime in this context right? I am pretty sure it is but just making sure.
 
  • #8
Yes- it is indeed an odd prime :) So (p-2)!= 1 mod p? Also, is this reason you added 'mod p' in the product because the inverses are only so in mod p?
 
  • #9
Ciaran said:
So (p-2)!= 1 mod p?

Yes, correct. As an example, take $p = 11$, so you have integers $2$ through $9$ to consider. Now let's see, the modular inverse of $2$ is $6$ since $2 \times 6 \equiv 12 \equiv 1 \pmod{11}$. The modular inverse of $3$ is $4$, the inverse of $4$ is $3$ (of course), the inverse of $5$ is $9$, the inverse of $6$ is $2$ (as seen before), and the inverse of $7$ Is $8$. At this point you have partitioned your set of integers (2, 3, 4, 5, 6, 7, 8, 9) into pairs of modular inverses (2, 6), (3, 4), (5, 9), (7, 8). Therefore we have:

$(11 - 2)! \equiv 2 \times 3 \times 4 \times 5 \times 6 \times 7 \times 8 \times 9 \equiv (2 \times 6) \times (3 \times 4) \times (5 \times 9) \times (7 \times 8) \equiv 1 \times 1 \times 1 \times 1 \equiv 1 \pmod{11}$

The same reasoning applies for any prime $p$, by using the properties of the modular inverse. Writing a rigorous proof for this is a nice exercise I think.

Now that you know what the remainder of $(p - 2)!$ modulo $p$ is, can you complete to find the remainder of $(p - 1)!$? What are the missing integers in the product?

Ciaran said:
Also, is this reason you added 'mod p' in the product because the inverses are only so in mod p?

Indeed, see more information at Modular multiplicative inverse - Wikipedia, the free encyclopedia, which explains modular inverses. They happen to be unique and behave much the same way as "normal" inverses like 3 and 1/3, except they are defined as integers modulo some other integer. Of course, if you haven't covered modular inverses yet you should want to prove some of its properties, which isn't too hard.
 
  • #10
You can also see that the argument breaks down if any integer is its own inverse, since we only get to multiply it once so it wouldn't cancel out with itself - this is why it's crucial to observe that the only integers that are their own inverses modulo a prime $p$ are $1$ and $-1$ (aka $p - 1$) as you've seen in the two previous questions, and handle these separately.
 
  • #11
Could I just multiply throughout by p-1? so (p-2)!(p-1)= (p-1)(1 mod p) so (p-1)!= p mod p- 1 mod p= -1 mod p
 
  • #12
Ciaran said:
Could I just multiply throughout by p-1? so (p-2)!(p-1)= (p-1)(1 mod p) so (p-1)!= p mod p- 1 mod p= -1 mod p

Certainly, and that is correct! You have just found that the product of all integers from $1$ to $p - 1$ always leaves a remainder of $-1$ ($p - 1$) modulo $p$ when $p$ is prime :cool:

(also known as one half of Wilson's theorem)
 
  • #13
That's truly beautiful. Thank you very much for all your help!
 

FAQ: Modular arithmetic and factorials

What is modular arithmetic?

Modular arithmetic is a branch of mathematics that deals with the remainder of a division. It involves dividing two numbers and finding the remainder, or "modulus", as the result. For example, 7 mod 3 would be 1, since 7 divided by 3 has a remainder of 1.

How is modular arithmetic useful?

Modular arithmetic has many practical applications, including in computer science, cryptography, and number theory. It is also used in everyday situations, such as telling time on a clock and calculating the day of the week.

What is a factorial?

A factorial is the product of all positive integers from 1 to a given number. It is denoted by an exclamation point (!) after the number. For example, 5! would be equal to 5 x 4 x 3 x 2 x 1 = 120.

How are modular arithmetic and factorials related?

Modular arithmetic can be used to find the last digit of a large factorial by finding the remainder of the factorial when divided by a smaller number. This is useful in probability and statistics, where factorials are commonly used in calculations.

Can modular arithmetic be used to solve equations involving factorials?

Yes, modular arithmetic can be used to solve equations involving factorials. By taking the modulus of both sides of the equation, it is possible to simplify and solve for the variable. This is especially useful in cryptography, where equations involving factorials are often used to create secure algorithms.

Similar threads

Back
Top