top of page

Modulus

The modulus operator % is used t return the remainder of a number.
(For example 5%2 will return 1 because 2 will go into 5 once while leaving one by itself)

Many advanced programs take advantage of the modulus operator. We will make a simple program which will check if a user-input number is prime or not.

Example:

Output:

modulus2.png
modulus1.png

A number will meet the requirements of being prime if there is a remainder while dividing by any other number or if the number is equal to 2,3,5, or 7.

  • Twitter
  • LinkedIn
  • discord-logo--v2
  • kisspng-github-pages-logo-repository-fork-github-logo-1-magentys-5b69de71b51265

Dragon Eye Intelligence LLC

bottom of page