How i calculate 2%3 and 3%2 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How i calculate 2%3 and 3%2

I think 3%2 =1 But 2%3=2 ?!

13th Jan 2020, 6:06 AM
Mohamed Gamal Apodaif
Mohamed Gamal Apodaif - avatar
3 Answers
+ 5
Modulo operator returns the remainder. So 2%3 is 2 because 2 is not divisible by 3 and 2 is the remainder.
13th Jan 2020, 6:41 AM
Avinesh
Avinesh - avatar
+ 4
0%3 = 0 1%3 = 1 2%3 = 2 3%3 = 0 4%3 = 1 5%3 = 2 6%3 = 0 7%3 = 1 8%3 = 2 9%3 = 0
13th Jan 2020, 6:40 AM
Seb TheS
Seb TheS - avatar
+ 1
modulo is pretty much 2%3 = 2 - (2 / 3) it returns the remainder of division. i.e. 9 % 2 = 1 9 - (9 / 2) = 1 To answer your question: 3-(3/2)=1 2-(2/3)=1
15th Jan 2020, 4:18 AM
Adler Vuong
Adler Vuong - avatar