0

var a = 8; a = a + a / (a % 3); document.write(a); //output= 12 //do u have any explanation?

17th Jun 2017, 12:09 AM
islam moheb
islam moheb - avatar
3 Respuestas
+ 6
% is the remainder after division. Called the 'modulus' or 'modulo' operator. 8 % 3 = ? 3 goes into 8 two times. Proof: 3 + 3 = 6. That's two 3's. 6 + 3 = 9, 9 > 8. Therefore we can't add another 3. Since 3 goes into 8 two times, what is the amount left over instead of adding again? Answer: 2 Proof: 8 = 6 + 2; Or, 6 = 8 - 2; So, 8 % 3 = 2. Then if we go back to the equation: a = a + a / (a % 3); a = a + a / (8 % 3); a = a + a / 2; a = 8 + 8 / 2; a = 8 + 4; a = 12;
17th Jun 2017, 12:16 AM
Rrestoring faith
Rrestoring faith - avatar
+ 6
No it is clearly​ explained by you......😎😎😎
17th Jun 2017, 12:24 AM
$Sadiq
$Sadiq - avatar
+ 6
good logic I am impressed,,,,,,,😇😇😇😚😚😚😚
17th Jun 2017, 12:24 AM
$Sadiq
$Sadiq - avatar