Search code examples
javascriptjquerymodulo

Modulo operator


9%4 = 1

1%4 and the answer is 1

2%4 and the answer is 2

Answer found. - CLOSED.


Solution

  • The meaning of Mod is that you take the remainder after doing the division.

    1 fits zero times in 4, so the remainder is 1.

    Here the wikipedia definition that explains in a little more detail:

    In mathematics the result of the modulo operation is the remainder of an arithmetic division. As is well known, an arithmetic division of two integers produces a quotient and a remainder.