+ 6

Function modulo is easy. For example 14 modulo 3. We must find number, which is smaller than 14 (<14), can be divided ( /) and it will be rational number (1, 2, 3... Not numbers like 3,123). It's 12 (12/3=4). Then we just subtract 14 and 12 (14-12). It's 2.

9 modulo 2= number which is <9 and can be /2. 8 is lower than 9 and can be divided by 2. Then just 9-8=1

16th Jun 2016, 8:47 PM
Utpal Kumar
Utpal Kumar - avatar
2 ответов
+ 4
14 / 3 = 4.66 take integer part: 4 4 * 3 = 12 14 - 12 = 2 14 % 3 = 2
28th Jan 2017, 6:49 AM
Mohammad Mehrabi
Mohammad Mehrabi - avatar
0
The modulus operator is very different from division. it does divide, but that number is discarded, whatever is left is printed. in the example of 25%7 we get this; 25/7 does not give a whole number, 21/7 is the closest since we cant increase the starting value of 25. this results in 3, but is discarded. 25-21 is all that matters here, and the answer to that is 4. this can be used to calculate for example; the number of leftover days in a year when you divide the days in a year (365) by the number of weeks in a year (52). 365%52 becomes 364/52 to make the result a whole number. 365-364=1, in this case 1 is printed. Hope this helps:)
20th Jun 2016, 1:15 AM
Utpal Kumar
Utpal Kumar - avatar