+ 1
could smbd explane me what "%" operator do?
a%b what is the result of this formula?
5 Answers
+ 6
a%b=Remainder
% gives you the remainder after all division is done.
Examples
-------------------------------------
11%2 .. this results in 1 because..
2 goes into 10 evenly, and leaves 1 remaining.
2,4,6,8,10 ... 1 remaining
18%5 .. this results in 3 because..
5 goes into 15 evenly and leaves 3 remaining.
5,10, 15 ... 3 remaining
-------------------------------------
practical use..
If n % 2 == 0 .. n is an even number .. because after 2 goes into n as much as possible there isn't a leftover. 2 goes into it evenly
Hope this helped
+ 5
Itâs the remainder after you divide the 2 numbers. Example 5/2 has a remainder of 1, so 5%2 =1.
+ 1
You could also think of it as: x%y
Substract y of x as often as posdible without the result getting negative... Or what you've propably been doing in the elementary school: "How often does y fit in x and what will remain (thats what you get: the remainder of the division)"
0
briefly its modulus
- 2
__________________