0
How to use modulus
how they worked? i mean how 9℅2 =1
3 Antworten
+ 1
Use %, not ℅. The modulus operator gives you the remainder of the euclidian division.
42%9 is 6 because 42 = 9*4 + 6
$a%$b is 0 if $a is a multiple of $b
$a%2 is 0 if $a is even and 1 if $a is odd
$a%10 gives you the last digit of $a
$a%100 gives you the last two digits of $a
etc.
+ 1
9%2 = 1 because 9/2 = 4.1 (4*2=8)
The REMAINDER will be the output of mod operator
0
modulus operator just gives the remainder of the two given numbers
FOR EG:TWO numbers are 4 and 2
4%2 gives the remainder zero(0) since 4/2 produces remainder zero
WHERE AS
2%4 also produces the remainder zero because 2 divides 4 but not with remainder zero(0). it produces some other reminder