Post Reply 
Back on Forum
03-06-2016, 07:10 PM
Post: #5
RE: Back on Forum
(03-06-2016 12:43 PM)ggauny@live.fr Wrote:  I am happy to be back with you all. I was in deasease.

Ah, welcome back then. :-)

(03-06-2016 12:43 PM)ggauny@live.fr Wrote:  I submit, as present, you a little routine that it is from Joe Horn and a friend of He which optmized. It is "friday the 13" in any year in gregorian.

Thank you very much.

Here is a version that works in any date mode (d.my, m.dy or y.md). It returns all dates where the 13th is a Friday, starting at the year entered in X. One data register is required – here I chose the I-register.

Code:
LBL A
FILL       ' fill stack with year
CLx        ' set month = 0
LBL 01
INC X      ' increment month
STO I      ' save month in I
#013
x>? Y      ' month < 13 ?
SKIP 004   ' then continue
STO/ Y     ' else set month = 1
STO/ I     ' also do so with saved month
INC Z      ' increment year in Z
INC T      ' and in T
→DATE      ' generate date according to mode setting
ENTER
WDAY       ' determine day of week
#005
-
x≠0?       ' is it not a Friday?
SKIP 005   ' then continue
CLα        ' else prepare output
DROP
αDATE      ' format date in Alpha
#005
PROMPT     ' show date & "5" for Friday
cDROP      ' DROP two levels
RCL I      ' recall month
GTO 01     ' and continue with next one

Example:

Code:
2010 [A]    =>  13.08.2010
     [R/S]  =>  13.05.2011
     [R/S]  =>  13.01.2012
     [R/S]  =>  13.04.2012
     [R/S]  =>  13.07.2012
     [R/S]  =>  13.09.2013
     [R/S]  =>  13.12.2013
     [R/S]  =>  13.06.2014
     [R/S]  =>  13.02.2015
      ...

But somehow I do not like this trial-and-error approach. I would prefer a more analytic algorithm: determine the day of week for 13 January, calculate the next Friday 13th from this, finally add a certain number of days for the next one.

But this would get much more complicated than the current method. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Back on Forum - ggauny@live.fr - 03-06-2016, 12:43 PM
RE: Back on Forum - Didier Lachieze - 03-06-2016, 02:31 PM
RE: Back on Forum - d b - 03-06-2016, 03:27 PM
RE: Back on Forum - Sylvain Cote - 03-06-2016, 03:46 PM
RE: Back on Forum - Dieter - 03-06-2016 07:10 PM
RE: Back on Forum - Dwight Sturrock - 03-06-2016, 07:18 PM
RE: Back on Forum - Jlouis - 03-06-2016, 07:40 PM
RE: Back on Forum - rprosperi - 03-06-2016, 09:33 PM
RE: Back on Forum - Etienne Victoria - 03-06-2016, 09:37 PM
RE: Back on Forum - ggauny@live.fr - 03-07-2016, 09:20 AM
RE: Back on Forum - ggauny@live.fr - 03-07-2016, 12:02 PM
RE: Back on Forum - Dieter - 03-07-2016, 12:57 PM
RE: Back on Forum - Thomas Radtke - 03-07-2016, 12:05 PM
RE: Back on Forum - Dieter - 03-09-2016, 09:14 PM
RE: Back on Forum - Dieter - 03-12-2016, 12:30 PM



User(s) browsing this thread: 1 Guest(s)