...

/

A Problem Partially Solved: Day of the Week

A Problem Partially Solved: Day of the Week

In this lesson, we will use arithmetic expressions to ascertain the day of the week given its calendar date.

Problem statement

Various devices in our homes record the current date as the month, day, and year. When a date is displayed, it often includes the day of the week. Is it possible to ascertain the day of the week from the month, day, and year? The answer is yes, as you will soon see.

Discussion

An algorithm known as Zeller’s congruence makes the determination that we need. According to this algorithm, a date such as December 31, 2020, is described as three components, as follows:

  • m is the month number, but one that is slightly different from what we are used to. March is month 3, April is month 4, and so on to December, which is month 12, but the
...
Access this course and 1400+ top-rated courses and projects.