Modular Arithmetic Proof

I’m doing a self study of math, and I encountered some rules.

First

Second

These are interesting rules, and I’d like to know the proofs of them.

Thanks!

What is a “primary number”? (It’s in both pages linked in the OP.) Is this a nonstandard term for “prime number”?

Yeah, it means “prime”. Or at least, I’ve seen proofs of both of those statements with “prime” in the place of “primary”.

The first is Fermat’s Little Theorem and the second is Wilson’s Theorem. See those references for proofs.

Standardly, “primary” ought to mean a power of a prime. (A primary ideal is, as a first approximation, a power of a prime ideal.) But those two theorems are valid only for actual primes.

As for proofs, well, this is not the place for this (I assume the references are), but they both depend on the fact that when p is a prime, the numbers 1,2,…,p-1 are a group under multiplication mod p. Fermat’s little theorem holds for any group, while Wilson’s theorem follows from the fact that p-1 is the only element of order 2.