0

How to use modulus

how they worked? i mean how 9℅2 =1

18th Sep 2016, 10:57 AM
Muhammad Yusuf Hanafi
Muhammad Yusuf Hanafi - avatar
3 Réponses
+ 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.
18th Sep 2016, 11:39 AM
Zen
Zen - avatar
+ 1
9%2 = 1 because 9/2 = 4.1 (4*2=8) The REMAINDER will be the output of mod operator
22nd Sep 2016, 1:13 PM
Kathleen Ulayao
Kathleen Ulayao - avatar
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
1st Oct 2016, 10:00 AM
vivekananda
vivekananda - avatar