20.09.2010, 18:26
Alright.
Here's a better example (this will make you understand it better):
(10 % 5)
Do you still remember this from the very beginning of school?
Let's say that example in words:
How many times can 5 join 10? 2 times. So 2.5 = 10 ; (also we write this (2) on the right side under the divider). Then you need to substract it so 10 -10 = 0. The remainder is 0.
Here's another example:
(4 % 3)
In words:
How many times can 3 join 4? 1 time. So 1.3 = 3 ; (don't forgot to write this (1) on the right side under the divider). Then you need to substract from it so 4 - 3 = 1. The remainder is 1.
Here's a better example (this will make you understand it better):
(10 % 5)
Code:
10 |_5___ -10 | 2 ___ | 0 |
Let's say that example in words:
How many times can 5 join 10? 2 times. So 2.5 = 10 ; (also we write this (2) on the right side under the divider). Then you need to substract it so 10 -10 = 0. The remainder is 0.
Here's another example:
(4 % 3)
Code:
4 |_3___ -3 | 1 ___ | 1 |
How many times can 3 join 4? 1 time. So 1.3 = 3 ; (don't forgot to write this (1) on the right side under the divider). Then you need to substract from it so 4 - 3 = 1. The remainder is 1.