(49G) Friday 13th calculation - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (49G) Friday 13th calculation (/thread-1675.html) |
(49G) Friday 13th calculation - Gerald H - 06-21-2014 02:09 PM The programme returns the dates of Friday 13th for a valid year entry using dd.mmyyyy format. The programme works for versions 1.19-6 & 2.10-8. Eg For 1,953 the programme returns 13.021953, 13.031953 & 13.111953. :: CK1&Dispatch BINT1 :: % 1000000. %/ %13 %+ BINT12 ZERO_DO % .01 %+ DUP % 13.063 DDAYS %7 %MOD %0= IT DUP LOOP DROP ; ; Improvements welcome. RE: HP 49G Friday 13th calculation - Joe Horn - 06-22-2014 06:16 AM Here's my ancient User RPL version, which was included in "One-Minute Marvels" by Richard Nelson and Wlodek Mier-Jedrzejowicz: Code: << 1000000 / 1.13 + 13 FOR d 6.133 d DDAYS 7 MOD NOT d IFT NEXT >> Since there are not many ways of doing it, the code looks very much like yours. Same input as yours: Just the desired year. However, my version assumes MDY mode. Changing it to DMY is left as an exercise for the student. RE: HP 49G Friday 13th calculation - HP67 - 06-22-2014 06:23 AM Is this from Conway? Is there a pointer to a formula or discussion on this? RE: HP 49G Friday 13th calculation - Gerald H - 06-22-2014 07:13 AM (06-22-2014 06:16 AM)Joe Horn Wrote: Here's my ancient User RPL version, which was included in "One-Minute Marvels" by Richard Nelson and Wlodek Mier-Jedrzejowicz: I probably copied Joe Horn's prog some time ago. Credit to him. RE: HP 49G Friday 13th calculation - Werner - 06-23-2014 08:11 AM Such a program should of course be independent of the date format setting. Try this: Code: \<< Cheers, Werner RE: HP 49G Friday 13th calculation - CosmicTruth - 06-23-2014 10:21 PM (06-22-2014 06:16 AM)Joe Horn Wrote: "One-Minute Marvels" "One-Minute Marvels" = pretty cool. ...I like PUSH POPs RE: HP 49G Friday 13th calculation - rprosperi - 06-24-2014 12:32 AM (06-23-2014 10:21 PM)CosmicTruth Wrote: "One-Minute Marvels" = pretty cool. Indeed! These are the very reason I, and a whole bunch of other folks, decided learning RPL was worth the time and effort. These and the EduCalc Technical Notes (also avail at hpcalc.org) are your best tools if trying to convince a friend (or yourself) to learn RPL. Real Good Stuff!! RE: HP 49G Friday 13th calculation - Joe Horn - 06-24-2014 05:03 AM (06-23-2014 08:11 AM)Werner Wrote: Such a program should of course be independent from the date format setting. Now THAT is a thing of beauty. RE: HP 49G Friday 13th calculation - Werner - 06-24-2014 07:30 AM Thanks, Joe. I missed the obvious shortcut: take -5. 6. START NEXT i.o. 1 12 START NEXT Now it's 86.5 bytes - shorter than your original ;-) Code: \<< Cheers, Werner RE: HP 49G Friday 13th calculation - Alberto Candel - 06-24-2014 02:05 PM Those are pretty. Some time ago I read somewhere, I forget where, that over the years, the most frequent day for a 13th was a Friday, or the other way around. It should be easy to verify with these programs. Good for a coffee break. RE: HP 49G Friday 13th calculation - Joe Horn - 06-24-2014 09:24 PM (06-24-2014 07:30 AM)Werner Wrote: Now it's 86.5 bytes - shorter than your original ;-) RE: HP 49G Friday 13th calculation - Joe Horn - 06-24-2014 10:16 PM (06-24-2014 02:05 PM)Alberto Candel Wrote: Those are pretty. Some time ago I read somewhere, I forget where, that over the years, the most frequent day for a 13th was a Friday, or the other way around. It should be easy to verify with these programs. Good for a coffe break. Unless my User RPL has bugs, you're right. The calendar repeats exactly every four centuries, so all we need to do is tally all 4800 13ths from 2000 through 2399. Here's what I got: 684 Thursdays & Saturdays 685 Mondays & Tuesdays 687 Sundays & Wednesdays 688 Fridays! |