Modulus | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Modulus

can anyone help me with this concept of modulus% I don't understand please help.

11th Dec 2017, 8:41 AM
Pius Githugu
5 Answers
+ 7
So lemme explain with 47%6. Note that 6*7+5=47. Hence 47/6 leaves a remaimder of 5, or 47%6=5
11th Dec 2017, 8:44 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
forget about floating point numbers for a moment and go back to elementary school where you calculated division like this: how often does 2 fit in 5? it fits in there 2 times leaving a remainder of 1 (2*2 = 4 -> 5-4 = 1) This remainder is what modulo calculates. Whatever is left in an integer division.
11th Dec 2017, 9:20 AM
Jeremy
Jeremy - avatar
+ 4
it just gives you the remainder
11th Dec 2017, 9:37 AM
Matt Pike
Matt Pike - avatar
+ 1
This code will help you to fully understed how modulus works: https://code.sololearn.com/Wcy7iV5Ln1ly/?ref=app
16th Dec 2017, 3:55 PM
Elazar Feinstein
Elazar Feinstein - avatar