The command mod(a,n) returns the least nonnegative residue of a mod n.
mod(43,10)
mod(3,10)
mod(-3,10)
mod(40,10)
We check the calculations in Example 5.18:
mod(178,4)
mod(178,5)
mod(178,9)