For Loops using Modulus %

What if we wanted to count backwards to 0? We can do a for loop for this as well! Simply reverse the sequence.

We can also add the ability to print only evens as well. We need to use a modulous to check if it has a remainder. If we divide our number by 2 and it has a remainder, we will skip it.

To get odd numbers, check with 1 vs 0.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ