0
Output (list)
y=11 x=2*(y%3) print(x*y) Solution: 44 What am I missing? Thanks.
4 Answers
+ 5
11%3 is 2 and x = 2*2 = 4
% is operator which gives reminder when we do x/y... as, 11 = 3*3 + 2. 11//3= 3 and 11%3 = 2
+ 1
% gives reminder... for example, 55%5 = 0 because (11*5) + 0 = 55
56%5 = 1 bcz (11*5)+1= 56
37%8 = 5 bcz (8*4)+5= 37
+ 1
tristach605 read this for modulus..it's in c++ but concept of modulus is same...
https://www.sololearn.com/learn/CPlusPlus/1609/
0
Thanks Kenta and Jay:).
So, when I solve for %, I have to always divide the remainder twice?
y=11
x=2*(y%3)
print(x*y)
y = 11
x = 2*(11%3) = 2 * (11/3 becomes 3.6/3 becomes 1.2 or "2")
y = 11
x = 2 * (2) = 4
print(11x4)
solution: 44