Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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)
22nd Oct 2019, 12:24 PM
Seb TheS
Seb TheS - avatar