The modulo operator (%) returns the remainder after dividing two numbers.
public static int mod(int num, int mod) {
int result = num % mod;
return result;
}
Function Call | Return Value | |||
---|---|---|---|---|
mod(9, 2) | → | |||
mod(13, 2) | → | |||
mod(10, 5) | → | |||
mod(30, 4) | → | |||
mod(8, 1) | → |
Experiment with this code on Gitpod.io