Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 4
https://www.sololearn.com/discuss/915565/?ref=app
https://www.sololearn.com/discuss/408503/?ref=app
https://www.sololearn.com/discuss/649643/?ref=app
https://www.sololearn.com/discuss/84229/?ref=app
https://www.sololearn.com/discuss/97727/?ref=app
https://www.sololearn.com/discuss/210573/?ref=app
https://www.sololearn.com/discuss/1669478/?ref=app
https://www.sololearn.com/discuss/551447/?ref=app
https://www.sololearn.com/discuss/1148398/?ref=app
https://www.sololearn.com/discuss/464872/?ref=app
+ 1
There are many different ways to think modulus, but I've thought it gives the left over after each perfect division.
For example 18 / 7
18 has 2 perfect divisions by 7,
18 - 7 * 2 = 4
18 % 7 = 4
=-=-=-=-=-=
Another way to think modulus, x % y subtracts or adds y to x until x is smallet natural number that is possible to get.
(Natural number is any non-negative whole number)
18 - 7 = 11
11 - 7 = 4
4 is smallest natural number possible, when you unlimitely subtract or add 7 to 18.
=-=-=-=-=-=
Computers calculate:
x % y
as:
x - (x // y) * y
(With // I meant floor division)