Using the Mod operator or %
What does it do?
The mod operator is basically another way to divide values, but instead of returning the result, it returns the remainder.
Example:
How you could use this
Basically, if you divide a number by two and it has no remainder, it is an even number.
So to check if something is an odd number, you can have it check if the remainder has any value other than 0
2 | print (x.. " is an even number" ) |
4 | print (x.. " is an odd number" ) |
Try experimenting with this and let me know if it works for you!