Calculate which day of the week a date falls in using modular arithmetic

10.3k Views Asked by At

In Summer Wars the main character (he is a mathematician) calculates the day of the week of someone's birthday (19/07/1992 is Sunday). I know (very) basic modular arithmetic but I can't figure out how to do it. Can someone point me to the right direction? It seems fun to do.

2

There are 2 best solutions below

1
On BEST ANSWER

The Zeller congruence is yet another method for reckoning the day of the week of a given date. Kim Larsen presents an implementation of a variant of the Zeller congruence in this article. (There is additional discussion of Larsen's formulation here.)

0
On

Before the Doomsday method (see link in Theo Buehler's comment), there was a formula due to Gauss. A good write-up is Berndt Schwerdtfeger, Gauss' calendar formula for the day of the week, available at http://berndt-schwerdtfeger.de/cal/cal.pdf