Doubt about mod

Asked

Viewed 101 times

-2

I know the mod is the rest of the division.

12%2 = 0
29%3 = 2

But could someone please let me know the reason for this?

12%18 = 12
52%58 = 52
  • 5

    As the name says, this is the rest of the division, these values happen because the "denominator" is larger than the "numerator", because how much else there would be on 12/18?

  • 2

    If you divide 12 by 18, the result is zero and the rest is 12. Python is only following what the math says :-)

2 answers

3

Let’s think about basic math:

If you take the results 12 and divide it by 18, as you would?

Well, I guess everybody here knows how to do a division account so let’s go.

 12 |18
- 0   0
 12 

Okay. After that point we’ll have to use the comma to continue the division, so it’s no longer a number whole. With this we come to the result that 12 % 18 == 12.

0

The MOD function returns the rest after number is divided by divisor.

  • Calculation of the rest of 12 by 18 = 12
  • Calculation of the remainder of 52 by 58 = 52

Browser other questions tagged

You are not signed in. Login or sign up in order to post.