Article 601QM A footnote to year share

A footnote to year share

by
John
from John D. Cook on (#601QM)

A couple weeks ago I wrote a post about the year share component of calculating the day of the week. To calculate the day of the week, you need to add the day of the week, a constant for the month, and the year share. Calculating year share is not that hard, but it's the hardest step to carry out in your head.

The year share of a date y is

5y/4 % 7

where y is the last two digits of a year. There's no need to multiply by 5, since you could compute

(y + y/4) % 7

but this still takes some effort if y is large.

The earlier post gave nine different ways to compute the year share, and the easiest in my opinion is method #6:

  1. Round y down to the most recent leap year and remember how much you had to round down. Call that amount r.
  2. Let t be the tens value and u the units value.
  3. Return (2t - u/2 + r) % 7.

In symbols,

  1. Let y = 4 y/4 and r = y - y.
  2. Let t = y'/10 and u = y % 10.
  3. Return (2t - u/2 + r) % 7.

This method has a longer description but is easier to carry out mentally as the following examples illustrate.

Examples

Let y = 97. Here are the calculations required by the direct method.

  1. y/4 = 24
  2. 97 + 24 = 121
  3. 121 % 7 = 2

Here are the calculations required by the second method.

  1. y = 96 and r = 1.
  2. t = 9 and u = 6.
  3. (2*9 - 3 + 1) % 7 = 2

The former requires adding two 2-digit numbers. The latter requires doubling a single digit number and subtracting another single digit number.

The former requires reducing a 3-digit number mod 7 and the latter requires reducing a 2-digit number mod 7. Furthermore, the 2-digit number is never more than 18.

Proof

To prove that the two methods are equivalent we have to prove

5y/4 2t - u/2 + r mod 7

which is kinda messy. The way t, u, and r are defined prevent this from being a simple algebraic calculation.

We can verify that

5y/4 2t - u/2 + r mod 7

for y = 0, 1, 2, ... 19 by brute force then prove the rest by induction. We'll show that if the congruence holds for y then it holds for y + 20.

Suppose you increase y by 20. Then 5y/4 increases by 25. The value of t increases by 2, and the values of u and r remain unchanged, so the right side increases by 4. Since 25 % 7 = 4, the congruence still holds.

The post A footnote to year share first appeared on John D. Cook.
External Content
Source RSS or Atom Feed
Feed Location http://feeds.feedburner.com/TheEndeavour?format=xml
Feed Title John D. Cook
Feed Link https://www.johndcook.com/blog
Reply 0 comments