Post Reply 
Easter Algorithm Bug
05-11-2017, 06:53 PM
Post: #1
Easter Algorithm Bug
The following code is supposed to output the a date of Easter for a given year. For some reason it doesn't output the right date and doesn't add the space after the month. If anyone can figure out what the bug in my code is, I would be greatly appreciated.

Code:

EXPORT easter(T)
BEGIN
  // Year (1583-9999)
  LOCAL A,B,C,D,E,K,M,N;
  LOCAL P,Q;
  IF T<1583 OR T>9999 THEN
    RETURN "Error - Year is invalid.";
  ELSE
    K:=IP(T/100);
    A:=T MOD 19;
    B:=T MOD 4;
    C:=T MOD 7;
    Q:=IP(K/4);
    P:=IP((8*K+13)/25);
    M:=15-P+K-Q MOD 30;
    D:=19*A+M MOD 30;
    N:=4+K-Q MOD 7;
    E:=2*B+4*C+6*D+N MOD 7;
    IF D+E<=9 THEN
      D:=22+D+E;
      M:=3;
    ELSE
      IF D==19 AND E==6 THEN
        D:=19;
        M:=4;
      ELSE
        IF D==28 AND E==6 AND A>10 THEN
          D:=18;
          M:=4;
        ELSE
          D:=D+E-9;
          M:=4;
        END;
      END;
    END;
    IF M==3 THEN
      RETURN cat("March ",D);
    ELSE
      RETURN cat("April ",D);
    END;
  END;
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Easter Algorithm Bug - codycbradio - 05-11-2017 06:53 PM
RE: Easter Algorithm Bug - Didier Lachieze - 05-11-2017, 08:33 PM



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