Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!hao!oddjob!gargoyle!ihnp4!occrsh!occrsh.ATT.COM!fubar From: fubar@squid.UUCP Newsgroups: comp.sys.ibm.pc Subject: day of week Message-ID: <141900013@occrsh.ATT.COM> Date: 28 Jan 88 11:50:00 GMT Lines: 48 Nf-ID: #N:occrsh.ATT.COM:141900013:000:1538 Nf-From: squid.UUCP!fubar Jan 28 05:50:00 1988 From squid!fubar Thu Jan 28 04:22 CDT 1988 remote from occrsh Subject: day of week *** *** PLEASE send replies to ihnp4!occrsh!squid!david *** > Here's a formula given in the book An Introduction to the Theory of Numbers, >by Niven and Zuckerman. > > Let M be the number of the month, defined so that Jan = 11, Feb = 12, >Mar = 1, Apr = 2, ..., Dec = 10. Let N be the number of the day within the >month. Let C be the hundreds in the year, and let Y be the rest of the year. >Let L be 1 for a leap year and 0 for a non-leap year. > >The formula > >(N + [2.6M - 0.2] + Y + [Y / 4] + [C / 4] - 2C - (1 + L)[M / 11]) mod 7 >yields 0 for Sunday, 1 for Monday, ..., 6 for Saturday. > >(Square brackets denote the greatest integer function.) So: Thursday, Jan 28, 1988, should yield 4: N = 28 (number of day within month) M = 11 (Jan = 11) C = 19 (Hundreds w/in year) Y = 88 (rest of year??) L = 1 (1988 is leap year) = (N + [2.6M - 0.2] + Y + [Y/4] + [C/4] - 2C - (1+L)[M/11]) mod 7 = (28 + [(2.6*11)-0.2] + 88 + [88/4] + [19/4] - (2*19) - (1+1)*[11/11]) mod 7 = (28 + [28.4] + 88 + [22] + [4.75] - 38 - 2) mod 7 = (28 + 29 + 88 + 22 + 5 - 38 - 2) mod 7 = 132 mod 7 = 6 ?? What is the correct formula for this? David Drexler uucp: {ihnp4,cbosgd,moss,uokmax}!occrsh!squid!david fidonet: 147/1 -or- 19/1 sneakernet: POB 1214, Bethany OK 73008 MaBellNet: [405] 848-8868 (voice) [405] 728-2463 (data - bbs)