HP Forums

Full Version: Friday the 13th on 17bii Solver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My brother-in-law called me today with a question about dates and days. He asked if there is a way to determine how many times Friday the 13th occurs in a given year (other than looking at the calendar for the current year, obviously).

I was aware of this site which has a very good algorithm for determining what day of the week a given date falls on. It occurred to me that this would be an excellent equation for the 17bii solver, making use of its included functions like sigma, IDIV, MOD, and of course L() and G().

The equation determines how many times a given day of the month (1-31) falls on a given day in a given year. You input the YEAR, day-of-month (DOM, 1-31), and DAY (0=Sunday, 6=Saturday), and solve for ANS.

For 2017, there are two Friday-the-13th's.

\(\Sigma\)(M:1:12:1:0xL(A:IDIV(14-M:12))xL(Y:YEAR-G(A))xL(MM:M+12xG(A)-2)+IF(MOD(DOM+G(Y)+IDIV(G(Y):4)-IDIV(G(Y):100)+IDIV(G(Y):400)+IDIV(31xG(MM):12):7)=DAY:1:0))-ANS
(01-13-2017 07:37 PM)Don Shepherd Wrote: [ -> ]It occurred to me that this would be an excellent equation for the 17bii solver, making use of its included functions like sigma, IDIV, MOD, and of course L() and G().

\(\Sigma\)(M:1:12:1:0xL(A:IDIV(14-M:12))xL(Y:YEAR-G(A))xL(MM:M+12xA-2)+IF(MOD(DOM+G(Y)+IDIV(G(Y):4)-IDIV(G(Y):100)+IDIV(G(Y):400)+IDIV(31xG(MM):12):7)=DAY:1:0))-ANS

Thanks Don, it seems it even works in the 17BII+ Silver Edition... (confirmed for 2015(3), 2016(1) and 2017(2) ).
(01-13-2017 08:09 PM)rprosperi Wrote: [ -> ]
(01-13-2017 07:37 PM)Don Shepherd Wrote: [ -> ]It occurred to me that this would be an excellent equation for the 17bii solver, making use of its included functions like sigma, IDIV, MOD, and of course L() and G().

\(\Sigma\)(M:1:12:1:0xL(A:IDIV(14-M:12))xL(Y:YEAR-G(A))xL(MM:M+12xA-2)+IF(MOD(DOM+G(Y)+IDIV(G(Y):4)-IDIV(G(Y):100)+IDIV(G(Y):400)+IDIV(31xG(MM):12):7)=DAY:1:0))-ANS

Thanks Don, it seems it even works in the 17BII+ Silver Edition... (confirmed for 2015(3), 2016(1) and 2017(2) ).
Thanks for testing that, Bob. I thought it would work on the plusses because it is not assigning values to menu variables, something the 17b and 17bii handle fine but the plusses generally can't.
(01-13-2017 07:37 PM)Don Shepherd Wrote: [ -> ]\(\Sigma\)(M:1:12:1:0xL(A:IDIV(14-M:12))xL(Y:YEAR-G(A))xL(MM:M+12xA-2)+IF(MOD(DOM+G(Y)+IDIV(G(Y):4)-IDIV(G(Y):100)+IDIV(G(Y):400)+IDIV(31xG(MM):12):7)=DAY:1:0))-ANS

Small suggested edit: For the second reference to variable 'A' in the expression

L(MM:M+12xA-2)

Change the direct reference of variable 'A' to G(A)

L(MM:M+12xG(A)-2)

so that the variable 'A' does not appear in the menu.

Very neat program! Someday I hope I'll master this programming language. Makes obfuscated C look like child's play Wink
1+

Alan
Why not move this into the General Software Library?

Alan
(01-14-2017 07:07 PM)mfleming Wrote: [ -> ]
(01-13-2017 07:37 PM)Don Shepherd Wrote: [ -> ]\(\Sigma\)(M:1:12:1:0xL(A:IDIV(14-M:12))xL(Y:YEAR-G(A))xL(MM:M+12xA-2)+IF(MOD(DOM+G(Y)+IDIV(G(Y):4)-IDIV(G(Y):100)+IDIV(G(Y):400)+IDIV(31xG(MM):12):7)=DAY:1:0))-ANS

Small suggested edit: For the second reference to variable 'A' in the expression

L(MM:M+12xA-2)

Change the direct reference of variable 'A' to G(A)

L(MM:M+12xG(A)-2)

so that the variable 'A' does not appear in the menu.

Very neat program! Someday I hope I'll master this programming language. Makes obfuscated C look like child's play Wink

Yeah, you are right, I missed that one. It was right on my actual calculator else the A would show up in the menu which I don't want, as you mentioned.

Good catch, I'll change the original post to reflect this.

thanks
(01-14-2017 08:21 PM)striegel Wrote: [ -> ]Why not move this into the General Software Library?

Alan

Alan, I'm not averse to that. The existing software library seems kind of disorganized, with subject lines like (17), HP17, (HP17), 17, and so on. All the stuff for one HP model is spread around that sub-forum. I don't know what it would take to clean it up and make it so that all software for a given model is together, perhaps Dave can address this.

It would be great if the software forum could itself be divided into sub-forums based on calculator model. This has probably been discussed before.

Don
Reference URL's