You are viewing a single comment's thread. Return to all comments →
n%5 will give you the remainder of the numbers to make n divisible by 5..
say n = 78
78%5 = 3 // so we have a remainder of 3 if we divide 78/5..
We however do not need the remainder to convert to a number divisible by 5 say we add 3 to 78 we will end up with 81, which is not divisible by 5.
We want to know how far we are from achieving a 5 from the modulus of 78 which is why we then subtract the modulus from 5..
In our case it would be we have a remainder of 3 and from 78 we require 2 (i.e 5-3(remainder) ) to be able to make our number divisible by 5..
sense?
Seems like cookies are disabled on this browser, please enable them to open this website
Grading Students
You are viewing a single comment's thread. Return to all comments →
n%5 will give you the remainder of the numbers to make n divisible by 5..
say n = 78
78%5 = 3 // so we have a remainder of 3 if we divide 78/5..
We however do not need the remainder to convert to a number divisible by 5 say we add 3 to 78 we will end up with 81, which is not divisible by 5.
We want to know how far we are from achieving a 5 from the modulus of 78 which is why we then subtract the modulus from 5..
In our case it would be we have a remainder of 3 and from 78 we require 2 (i.e 5-3(remainder) ) to be able to make our number divisible by 5..
sense?