When that breaks down, you can no longer invert numbers in a reversible way. aka `1/(1/x) == x` no longer holds true. This means you can no longer easily manipulate values or equations using the common set of properties established for most mathematics, hence "not maths friendly".
There are also finite (Galois) fields GF(p^n) of size p^n (positive integer powers of p)
These can be exhibited by polynomials with coefficients in the GF(p) field with up to n terms.
Eg for p = 2 and n = 3
0
1
x
1 + x
1 + x + x^2
1 + x^2
x + x^2
x^2
https://en.wikipedia.org/wiki/Multiplicative_group_of_intege...
In particular, all non-zero values have a unique inverse:
> As 251 is prime, this reduction rule is math-friendly. By that, I mean that for any x other than zero, there is some y such that x * y == 1. For example, taking x of 16, we have 16 * 204 == 1. This property is not true for the 256 == 0 reduction rule; with that rule, there is no y such that 16 * y == 1. Where it exists, this y can be called inv(x) or 1/x.
The integers mod n >= 1 are always a group (under addition), only the field structure requires prime n.
In actual practice what we typically do is select primes that are "near" a power of two, called the Mersenne primes (which have the form 2^N - 1) and Pseudo-Mersenne primes (2^N - a). These have special properties that let us work with them more efficiently. Modern algorithms for these kinds of special cases are branchless, divisionless, and constant time, even if they're not quite as fast as operations in the binary fields.