0

# Why This ?

Why 10%20 equal 10?

20 Answers

+ 6

If you try to divide 10 by 20, it is possible zero times.
And you will keep a remainder of 10.

+ 2

Probably it helps more if you understand what you calculate with modulo (the remainder).
Have you understood it? Generally?

+ 2

I understood when 2%2 = 0,
120%20 = 0,
13%2 = 1
but this one of the first number less than the second got me confused bro¡¡¡
i.e 2%12, 4%12¡!!

+ 2

You need to know, in x%y how many times y goes to x, then subtract it from x.

+ 2

Seb TheS Omg god a shorter way lmao

+ 1

x%y = y*(float(x/y)-int(x/y))
10%20 = 20*(float(10/20)-int(10/20))
= 20*(float(0.5)-int(0.5))
= 20*(0.5-0)
=10

+ 1

Okay, problem seems to be solved even if in a bit convoluted way. ;)
Nightynight guys...

0

Seb TheS, Is that the proper way to do it ... or are there other ways?

0

The Learner There are other ways, atleast I could have taken these int() and float() away, If I just would have known the language, that was used to be able to use floor division.

0

btw, Thanks for answering my question guys 👍

0

I will offer the elementary school way of thinking (which I'm sort of using myself).
87%9
How often does the 9 fit whole into 87?
Answer: 9 times. 9*9 is 81.
And what will be left?
87-81=6.
Now do the same with 10 and 20, or 2 and 12, or 4 and 12.

0

Seb, not everybody understands when you write a lot of numbers and not a single word.
(IF you understand, it is the most elegant way of course.)

0

x%y = y*(float(x/y)-int(x/y))
cyberpunk2077 = x%y = x-int(x/y)

0

Oh, I see, we ended up writing the same. ^^

0

x%y = y*(float(x/y)-int(x/y))
cyberpunk2077 = x%y = x-int(x/y)

0

cyberpunk... what? oO

0

HonFu 10%20 =
how often does 20 fit in 10?
ans = 0 ? 0*20
ans = 0
ans = 10 - 0
ans = 10 ?
omg

0

^^

0

10%3 = 10-int(10/3)=7
10%3 = 3*(float(10/3)-int(10/3))=1
10%3 = 10-3*int(10/3)=1

0

# Thank you man :)
for i in "Thank you":
print(i)