+ 1

How 7%(5//2) = 1 ???

4th Jun 2019, 3:25 AM
Akshat Patidar
Akshat Patidar - avatar
2 Respostas
+ 2
Simple: 5//2=2 and 7%2=1
4th Jun 2019, 10:20 AM
CodeFu
CodeFu - avatar
+ 1
5//2 is 5/2 without decimal. 5/2 = 2.5 5//2 = 2 7%2=1 In modulo operator you can always subtract or add anything that is dividible by the second operand (2) to the first operand (7). First operand = 7 Second operand = 2 We can subtract 6 (3*2) from the first operand. 7-6 = 1 The first operand is now 1. When the first operand is positive, but less than the second operand, the result is the first operand. That's why 7%2=1.
4th Jun 2019, 5:51 AM
Seb TheS
Seb TheS - avatar