#### Easter Sunday

/* easter(+Year, ?Month, ?Day) is true if the date of Easter Sunday */
/* for the given Year (greater than 1582) is Month/Day. */
/* Based on Knuth exercise 1.3.2-14 and 15 */
/* e.g. easter(2008, Month, Day) gives Month=March, Day=23 */
easter(Year, Month, Day):-
Year > 1582,
GoldenNumber is Year mod 19 + 1,
Century is Year // 100 + 1,
X is int(3 * Century / 4) - 12,
Z is int((8 * Century + 5) / 25) - 5,
Sunday is int(5 * Year / 4) - X - 10,
Epact is (11 * GoldenNumber + 20 + Z - X) mod 30,
easter_1(Epact, Epact1),
easter_2(Epact1, GoldenNumber, Epact2),
FullMoon is 44 - Epact2,
easter_3(FullMoon, FullMoon1),
FullMoon2 is FullMoon1 + 7 - (Sunday + FullMoon1) mod 7,
easter_4(FullMoon2, Month, Day).
easter_1(Epact, Epact1):-
Epact < 0, !,
Epact1 is 30 + Epact.
easter_1(Epact, Epact).
easter_2(25, GoldenNumber, 26):-
GoldenNumber > 11, !.
easter_2(24, _, 25):-!.
easter_2(Epact1, _, Epact1).
easter_3(FullMoon, FullMoon1):-
FullMoon < 21, !,
FullMoon1 is FullMoon + 30.
easter_3(FullMoon, FullMoon).
easter_4(FullMoon, `April`, Day):-
FullMoon > 31, !,
Day is FullMoon - 31.
easter_4(FullMoon, `March`, FullMoon).

LPA Index
Home Page