What is the purpose of the mod function in Java?
In Java, the modulus operator (%) is used to calculate the remainder of a division between two numbers. For example, the result of 10 % 3 is 1, because the remainder of dividing 10 by 3 is 1. This operator is often used in loops to check if one number can be evenly divided by another.