The Museum of HP Calculators

HP Forum Archive 19

 HP 35s Day of the week programMessage #1 Posted by Pablo P (Spain) on 23 June 2010, 4:38 p.m. Hi all, I was watching a tv show about an extraordinary man who calculates mentally the day of the week of any date. Then I wrote this program for the HP 35s that uses one of that algorithms. ```DAY OF THE WEEK FOR HP 35s (FROM 1901 TO 2099) Table of Contents ================= 1 Using the program 2 Program listing 3 Registers 4 Revision 1 Using the program ~~~~~~~~~~~~~~~~~~~~ First execute the program: XEQ W ENTER. Insert the day and press R/S. Insert the month and press R/S. Insert the year (from 1901 to 2099) and press R/S. Then it will show a number that corresponds to the day of the week according to this table: Day Number -----------+-------- Sunday 0 Monday 1 Tuesday 2 Wednesday 3 Thursday 4 Friday 5 Saturday 6 2 Program listing ~~~~~~~~~~~~~~~~~~ Line Instruction ------+-------------------- W001 LBL W W002 INPUT D W003 INPUT M W004 INPUT Y W005 033614625035 W006 1E13 W007 10 W008 RCL M W009 y^x W010 ÷ W011 ÷ W012 FP W013 10 W014 x W015 IP W016 STO N W017 RCL Y W018 4 W019 RMDR W020 x!=0? ;(not equal) W021 GTO W038 W022 RCL Y W023 100 W024 RMDR W025 x!=0? ;(not equal) W026 GTO W032 W027 RCL Y W028 400 W029 RMDR W030 x!=0? ;(not equal) W031 GTO W038 W032 RCL M W033 3 W034 x>y? W035 GTO W038 W036 1 W037 STO+ N W038 RCL Y W039 1 W040 - W041 ENTER W042 ENTER W043 ENTER W044 100 W045 INT÷ W046 1 W047 + W048 4 W049 INT÷ W050 -3 W051 x W052 x<>y W053 4 W054 INT÷ W055 + W056 + W057 RCL N W058 + W059 RCL D W060 + W061 7 W062 RMDR W063 STO W W064 VIEW W W065 RTN 234 Bytes 3 Registers ~~~~~~~~~~~~ Register Use Notes ----------+-----------------+---------------- D Day of month M Month Y Year N Modulus Internal usage W Day of the week 4 Revision ~~~~~~~~~~~ 06/23/10 - Initial release ``` Edited: 23 June 2010, 5:29 p.m. after one or more responses were posted

 Re: HP 35s Day of the week programMessage #2 Posted by Pablo P (Spain) on 23 June 2010, 5:18 p.m.,in response to message #1 by Pablo P (Spain) Sorry, there is a problem with leap years. I will fix it.

 Re: HP 35s Day of the week programMessage #3 Posted by Pablo P (Spain) on 23 June 2010, 5:31 p.m.,in response to message #1 by Pablo P (Spain) Fixed.

 Re: HP 35s Day of the week programMessage #4 Posted by Jeff O. on 24 June 2010, 4:30 p.m.,in response to message #1 by Pablo P (Spain) Hello Pablo, Thanks for the program. I think I saw the show about the man who could tell the day of the week for any given date. There was a discussion here a while back about a method to determine on which day of the week the last of February, 7 March, 4 April, 9 May, 6 June, 11 July, 8 August, 5 September, 10 October, 7 November and 12 December will fall in a given year. From there you can quickly figure what day of week any other date will fall. It was called the "doomsday" method, but I preferred to think of it as the "magic day", so that's what I called the program I wrote to calculate it. The meat of the program is the equation below, which was found at the links in message 8 of the discussion. RMDR((2+REGX+IP(REGX/4)-IP(REGX/100)+IP(REGX/400),7) The year you are interested in must be in stack register x. . Edited: 25 June 2010, 1:17 p.m.

Go back to the main exhibit hall