- 1
Print (num%17)
What the % meaning
4 ответов
+ 4
The operator of the remainder of the number %
(for example: 17 % 3 = 2)
1. Take the nearest number when divided by 3 would be zero. That's apparently 15
2. Subtract 15 from 17 and the result is your answer.
I would also recommend to deal with the division modulo negative numbers for example: -2%7 -> 5 why so?
0
% is the modulo operator...
it return the rest of whole division of left-hand-side argument by right-hand-side argument:
5%2 = 1
11%3 = 2
result is always integer in range 0 (included) to right-hand-side argument (excluded)
0
often used to test divisibility of a number by right-hand-side argument: if equals 0, number is divisible by right-hand-side argument ;)