0
var a = 8; a = a + a / (a % 3); document.write(a); //output= 12 //do u have any explanation?
3 Antworten
+ 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;
+ 6
No it is clearly explained by you......😎😎😎
+ 6
good logic I am impressed,,,,,,,😇😇😇😚😚😚😚