+ 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😭😭😭
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.
+ 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.
+ 3
thanks Álvaro😉
+ 2
@Andrew Stepanov: 👍 thank you so much for pointing out my mistake. It's now corrected. Please report back if anything else is wrong.
+ 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
0
bacuse