30! [mod 899] ?
30!mod899?=
899=29∗31=p∗q| let p=29 and q=31 so \textcolor[rgb]{1,0,0}{p and q are relatively prim!}
I. 30!modp=0, because p=29 is divider of 30! (30!=30∗29∗28∗...3∗2∗1)
30!modp=r, if p=29 we have r=0
II. 30!modq=sq=31 is a prime number so (31−1)!≡−1mod31 [Wilson]
(31−1)!≡−1+31mod31 or 30!≡30mod31 we have s=30
III.
Since p and q are relatively prime, there are integers a and b such that ap+bq=1. You can find a and b using the Extended Euclidean algorithm.
http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
So a=46 and b=-43, so 29*(46) + 31*(-43) = 1
IV.
Then
30!mod(p∗q)=a∗p∗s+b∗q∗r30!mod(899)=46∗29∗30+(−43)∗31∗0=46∗29∗30=40020
V.
30!mod899=40020mod899=464
30! [mod 899] ?
30!mod899?=
899=29∗31=p∗q| let p=29 and q=31 so \textcolor[rgb]{1,0,0}{p and q are relatively prim!}
I. 30!modp=0, because p=29 is divider of 30! (30!=30∗29∗28∗...3∗2∗1)
30!modp=r, if p=29 we have r=0
II. 30!modq=sq=31 is a prime number so (31−1)!≡−1mod31 [Wilson]
(31−1)!≡−1+31mod31 or 30!≡30mod31 we have s=30
III.
Since p and q are relatively prime, there are integers a and b such that ap+bq=1. You can find a and b using the Extended Euclidean algorithm.
http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
So a=46 and b=-43, so 29*(46) + 31*(-43) = 1
IV.
Then
30!mod(p∗q)=a∗p∗s+b∗q∗r30!mod(899)=46∗29∗30+(−43)∗31∗0=46∗29∗30=40020
V.
30!mod899=40020mod899=464