Zellers Congruence

The Task

Most of us remember our birthdays but not our birth day!  One way to calculate this is to use a formula called Zellers Congruence.  The formula is

day = (abs(2.6m – 0.2) + k + y + (y div 4) + (c div 4) – 2c)) mod 7

The result will be a number in the range 1 to 7.  Print out the day if Sunday =1, Monday = 2, etc

The variables are:

  • m = month.  Take January as month 10, February and month 11, and March as month 1, etc.  December will be 10.
  • k = the day of the month
  • c = the century (i.e. 20 in 2006)
  • y = the year (i.e. the 06 in 2006)

Can you write a program that calculates the day that you were born on?

Credit Blundell@MonktonCoombe

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.