hello im from germany and so my englisch isnt very good. can somebody explain what the modulus does? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

hello im from germany and so my englisch isnt very good. can somebody explain what the modulus does?

(var example = 26 % 6; //Output = 2)

13th Apr 2016, 7:11 PM
datweirdboii
datweirdboii - avatar
4 Answers
+ 3
For your example, 26 divided by 6 is 4 with a remainder of 2. The modulus returns the number that is the remainder of a calculation. So, 26 modulus 6 will return an answer of 2.
20th Jun 2016, 2:34 PM
Neil Russell
Neil Russell - avatar
+ 1
Er gibt dir den resteiner division: 26/6 geht nicht. Die nächst kleinere zahl wäre 24, 24/6 geht und dann hadt du 2 rest
28th Apr 2016, 7:19 PM
hallou
hallou - avatar
+ 1
Divide 5 by 2 and you get 2 as quotient (2*2) and 1 (+1=5) as remainder. The remainder part is what the modulus gives.
10th Jul 2016, 12:41 PM
Dan
0
it's the remainder after integer division. examples... 7/3=1 or 26/6=2 or 6/2=0
10th Jun 2016, 4:22 PM
johnc