If we want to get the remainder of a division operation, we can use the modulo operator (%
). Try it:
5 % 2
The result is 1
.
Remainder Refresher
5
divided by 2
is exactly 2.5
. If we are dividing using only whole numbers, then the answer would be 2
instead.
Think of it this way. If we have 5 pennies and split them into two even piles, each pile would have 2 pennies and there would be 1 penny left over. That is the remainder.