In: Computer Science
Compute 20191023 mod 7 without using calculator. Show every step.
To find the remainder(modulus operator) without using a calculator , we need to find prime factors of the number.
Suppose a number n can be written as n = a*b where a and b are prime numbers, and we need to find the remainder of n with a number c, i.e n%c, then remainder can be calculated as n%c = (a%c)*(b%c). If the result is a number greater than c, then we calculate the remainder of the result with c again to get our desired result.
Similarly for n = a*b*c where a,b,c are prime numbers , n%d = (a%d)*(b%d)*(c%d) and calculating remainder again if result was greater than d.
For eg: to calculate 2491 mod 6, 2491 can be written as 53*47
So 2491%6 = (53%6)*(47%6) = 5*5 = 25
As 25 is greater than 6, we calculate 25%6 which is equal to 1 and that is our desired answer.
Now,
20191023 = 3*3*397*5651 where all of these are prime numbers
20191023%7 = (3%7)*(3%7)*(397%7)*(5651%7) = 3*3*5*2 = 90
As 90 is greater than 7, we calculate 90%7 = 6
And 6 is our desired answer!