A million days from now
February 21st, 2004 admin
I am reading a book called In Code - A young woman’s mathematical journey written by Sarah Flannery. In one of the chapters while trying to explain the concept of modulo arithmetic, she poses an interesting question along the lines of,
“Say today is Saturday, what day of the week will the millionth day from today be?”
The answer uses some very simple principles of modulo arithmetic. And I thought it was fascinating the way it is solved so easily. The question is simply,
If the days of the week are labeled 1,2…7 (for Monday, Tuesday, …, Sunday respectively) then the nth day from today would be more than today by remainder when you divide n by 7.
nth day from today = today + remainder when n is divided by 7 (or divided into 7, whichever convention you are comfortable with)
nth day from today = today + n mod 7 (the mod part is therefore just another way of saying remainder)
But how do we find n mod 7? Especially when n is something huge like 1000000? That is where we need to make some useful observations about the modulus operator.
x mod a = y mod a, implies, x - y is divisible by a (figure shows why)
What can we say about xn mod a and yn mod a?
If x mod a = y mod a, then xn mod a = yn mod a.
In other words, if x - y is divisible by a then xn-yn is divisible by a too.
xn mod a = yn mod a is true only if xn - yn is divisible by a. Is that the case?
YES! And that is because xn-yn = (x-y)(some factor)
examples:
x2-y2 = (x-y)(x+y)
x3-y3 = (x-y)(x2 + xy + y2)
and so on.
Since x mod a = y mod a, ie x - y is divisible by a, (x-y)(some factor) is also divisible by a (since the “some factor” has no fractions and is therefore an integer).
OK, so what day is a million days from today?
million days from today = today + 100000 mod 7
how can we solve 1000000 mod 7?
Observe that 10 mod 7 = 3 (or in other words 3 mod 7)
10 mod 7 = 3 mod 7
Sqaring both sides confidently because we proved that exponentiation on both sides retains the equality,
100 mod 7 = 9 mod 7
Reducing right hand expression, by observing 9 mod 7 = 2 = 2 mod 7
100 mod 7 = 2 mod 7
Cubing both sides,
1000000 mod 7 = 8 mod 7
Observing that 8 mod 7 = 1
1000000 mod 7 = 1
a million days from now = today + 1 = Saturday + 1 = Sunday. (Something tells me that no one would worry about weekdays and weekends then)
Posted in Tidbits | No Comments »