Modular arithmetic basics - Mathematics Stack Exchange
elementary number theory - $n \equiv 5$ (mod $6$) has a prime factor $p$ of $n$ such that $p \equiv 5$ (mod $6$) - Mathematics Stack Exchange
what is mod?
Understanding modulus - Stack Overflow
What is modulo (mod) operation?
How much is 17 mod 3?
17 mod 3 equals 2 since dividing 17 by 3 gives a quotient of 5 and a remainder of 2. The remainder is the result of the modulus operation. In simpler terms, 17 mod 3 = 2.
What is the difference between mod and remainder?
Videos
Your proof is pretty good, though you missed that there are primes congruent to $2$ and $3$ mod $6$ (namely, $2$ and $3$), though we would not have $n\equiv5\pmod6$ if $2$ or $3$ divided $n$.
Your proof is correct but is better phrased as proof of the contrapositive:
If all prime factors of $n$ are congruent to $1$ mod $6$, then so is $n$.
Wikipedia doesn't explain it really well. I know it works like a clock, where after 24 it goes back to 1 (20+5=1) but it never explains how to know the "limit" and the only examples are n¹≡n² (mod n³)
The problem with your calculation 5 % 6 is that it will ALWAYS give you remainder 5. If you tried 6 % 5, that will give you 1 for an answer.
This isn't a programming question, as modulus is a mathematical operator not at all unique to Java or any programming language, but 5 mod 6 = 5 as it is the remainder after dividing by 6 (5 < 6 so the remainder is 5). 6 mod 5 = 1, as 6 > 5, so you subtract 5, then you are left with 1 and 1 < 6.
If it helps, here is a pseudocode illustration of modulus (for positive integers):
integer mod(integer a, integer b) {
if a < b:
return a
else:
return mod(a - b, b)
}