% Ostersonntag Berechnung % Easter Sunday Calculation % Written in GNU Prolog also runs with SWI Prolog % Author: Detlef Sax % So 22 Dez 2002 13:45:22 CET % This program is free software; you can redistribute it and/or modify it % under the terms of the GNU General Public License as published by the Free % Software Foundation; either version 2 of the License, or (at your option) % any later version. % % This program is distributed in the hope that it will be useful, but WITHOUT % ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or % FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for % more details. % % You should have received a copy of the GNU General Public License along % with this program; if not, write to the Free Software Foundation, Inc., 675 % Mass Ave, Cambridge, MA 02139, USA. start :- write('Jahr eingeben. Eingabe mit Punkt/Return abschliessen: '), nl, write('Year input. Submit input with Dot and Return: '), nl, read(Jahr), eastersun(Jahr, Monat, Tag), write('Ostersonntag für das Jahr: '), nl, write('Easter Sunday for Year: '), nl, write(Jahr), nl, write(' ist am/on: '), write(Tag), write('.'), write(Monat), write('.'), nl, halt. %eastersun(+Jahr, -Monat, -Tag). eastersun(Jahr, Monat, Tag) :- test1583(Jahr), clavois(Jahr, Monat, Tag). test1583(Jahr) :- Jahr >= 1583, Jahr =< 8702. %gauss(Jahr, Monat, Tag) :- % k is Jahr // 100, /* Algorithmus (Gauß) der Physkalisch technischen Bundesanstalt: 1. K= INT (X / 100); 2. M= 15 + INT ((3 * K + 3) / 4) - INT ((8 * K + 13) / 25); 3. S= 2 - INT ((3 * K + 3) / 4); 4. A= MOD (X,19); 5. D= MOD (19 * A + M, 30); 6. R= INT (D / 29) + (INT (D / 28) - INT (D / 29)) * INT (A / 11); 7. OG = 21 + D - R; 8. SZ = 7 - MOD (X + INT (X / 4) + S, 7); 9. OE = 7 - MOD (OG - SZ, 7); Dann ist OS = OG + OE das Datum des Ostersonntags, als Datum im Monat März dargestellt. Der 32. März entspricht dem 1. April usw. */ clavois(Jahr, Monat, Tag) :- % Jahrhundert: JH is Jahr // 100 + 1, % Goldene Zahl: GZ is ( Jahr mod 19 ) + 1, % Schaltjahrkorrektur: X is ( JH * 3 // 4 ) - 12, % Mondjahrkorrektur: Z is ( ( JH * 8 + 5 ) // 25 ) - 5, % Sonntag: D is ( Jahr * 5 // 4 ) - X - 10, % Epact: EP1 is ( GZ * 11 + 20 + Z - X ) mod 30, epact(EP1, GZ, EP), monattag(EP, Day), sonntag(Day, D, Sonntag), ostersonntag(Sonntag, Monat, Tag). epact(EP1, GZ, EP) :- EP1 =:= 25, GZ > 11, EP is EP1 + 1. epact(EP1, _, EP) :- EP1 =:= 24, EP is EP1 + 1. epact(EP1, _, EP) :- EP is EP1. monattag(EP, Tag) :- Day is 44 - EP, Day < 21, Tag is Day + 30. monattag(EP, Tag) :- Tag is 44 - EP. sonntag(Tag, D, Sonntag) :- Sonntag is Tag + 7 - ((D + Tag) mod 7). ostersonntag(Sonntag, Monat, Tag) :- Sonntag > 31, Monat is 4, Tag is Sonntag - 31. ostersonntag(Sonntag, Monat, Tag) :- Monat is 3, Tag is Sonntag. :- initialization(start).