+ 3

Programmers am stuck i don't know how this modulus operation works. I mean like if it was addition you add so what do i do??

😨😨😨What do i do😭😭😭

21st May 2017, 9:22 AM
Raz
Raz - avatar
6 Antworten
+ 2
Say you wanted to calculate 24 % 5 by hand. What's the quotient? I mean, how many times does 5 go into 24? It's 4 times, because 5*4=20, which is <24. The quotient cannot be 5, because 5*5=25, which is not <24. Ok, so 4 is the quotient. Now 24 % 5 is the remainder, that is, 24-5*4 = 4. So 24 % 5 = 4.
21st May 2017, 10:01 AM
Álvaro
+ 4
At the end Álvaro wanted to write 24%5=4, but he unexpectedly mixed the keys and wrote 25%4=4. 4%3=1 (4/3=1 and 1 remains undivided) 5%3=2 (5/3=1 and 2 remains undivided) 7%3=1 (7/3=2 and 1 remains undivided after the division) So for the result we get only a part which is left undivided, not the result of division.
24th May 2017, 4:30 PM
Andrew Stepanov
Andrew Stepanov - avatar
+ 3
thanks Álvaro😉
21st May 2017, 10:04 AM
Raz
Raz - avatar
+ 2
@Andrew Stepanov: 👍 thank you so much for pointing out my mistake. It's now corrected. Please report back if anything else is wrong.
24th May 2017, 6:06 PM
Álvaro
+ 1
what this means is that. % is asking you, Hey buddy what's the remainder when 2 divides 7 which would be 1, while / is asking you, Hello please how many times can 2 go into 7 which would be 3
30th May 2017, 7:41 AM
dave
0
bacuse
10th Jun 2017, 1:46 PM
Kellie Jones