# Wilson's Theorem

1. Apr 19, 2009

### duki

1. The problem statement, all variables and given/known data

Find the remainder when 34! is divided by 37.

2. Relevant equations

Wilson's Theorem

3. The attempt at a solution

I understand that (p-1)! = (-1)(mod p) and that (p-2)! = (1)(mod p). I don't understand how to apply this to (p-3)! though.

2. Apr 19, 2009

### matticus

you know that (p-2)! = 1 (mod p). So (p-3)!*(p-2) = 1 (mod p). In this situation, 34!*35 = 1 (mod 37). Call 34! 'x' and then solve 35x = 1 mod 37, which has a unique solution since gcd(35,37) = 1.

3. Apr 19, 2009

### duki

So do you do..

1 = 35x
1 = (-2)x
1 = (-2)(-18)

R = -18 + 37 = 19 ??

4. Apr 20, 2009

### Dick

35*19 isn't 1 mod 37. Don't you mean 1=(-2)(-19)? It's easy enough to check your answers with a quick calculation.

5. Apr 20, 2009

### duki

You're right. Thanks for the help.

6. Apr 24, 2009

### duki

I'm trying to find 33! / 37 now.

I have gotten to (-3)x = 18 (mod 37)... but I can't figure out what x is.

7. Apr 24, 2009