Working out a remainder
The modulo operator (%) will work out the remainder left over when one value goes into another:
This will print:
30 / 6 gives 0. Because 6 goes into 30 exactly 5 times there is no remainder; so 0 is printed.
This would output:
30 / 7 gives 2. Because 7 goes into 30 4 times (28) it leaves a remainder of 2.
To check if a number is odd or even you can see if it leaves a remainder when divided by 2:
If you enter an even number (remainder of 0):
If you enter an odd number (remainder of 1):
Try this practice question out when you have tried inputs first: