# Interactive Modular Arithmetic

This interactive demonstrates the properties of modular arithmetic on a number-line. The modulus operator, represented as , is the same operation as dividing x by a and returning the remainder of the division. The first control point controls the input number *x* and the second control point controls the number *a*. Click and drag either point to see the properties of modular arithmetic.

## Examples

5 mod 3 is equal to 2 because the remainder of 5 divided by 3 is 2.

7 mod 2 is equal to 1 because the remainder of 7 divided by 2 is 1.

17 mod 6 is equal to 5 because the remainder of 17 divided by 6 is 5. If we divide 17 by 6 we find that 6 fits into 17 two times and 17 - 2(6) = 5.

## Applications

An alternative way to visualize modular arithmetic is through rotation:

The total rotation mod 360 is equal to the current angle in degrees. Click and drag the control point to change the total rotation. The equation below describes this mathematically:

Where r represents the total rotation, 360 ° represents one full rotation, and θ represents the current angle or direction.