#include #include using namespace std; //Output the date of Easter in the western churches //for any year in the range 1583 to 99999 AD inclusive. //From Donald E. Knuth, "The Art of Computer Programming, //Volume 1: Fundamental Algorithms", 2nd ed. (1973), pp. 155-156. int main() { const int year {2025}; if (year <= 1582 || year >= 100000) { cerr << "Sorry, year is out of range.\n"; return EXIT_FAILURE; } const int golden {year % 19 + 1}; //Metonic cycle const int century {year / 100 + 1}; //the century that contains the year const int x {3 * century / 4 - 12}; //# of times leap year cancelled const int z {(8 * century + 5) / 25 - 5}; //sync with Moon's orbit const int day {5 * year / 4 - x - 10}; int epact {(11 * golden + 20 + z - x) % 30}; //age of moon on Jan 1 if (epact < 0) { epact += 30; //Make sure the epact is non-negative. } if (epact == 24 || epact == 25 && golden > 11) { ++epact; } int n {44 - epact}; //The nth day of March is a full moon. if (n < 21) { //March 21 is the vernal equinox. n += 30; //Get the full moon after the equinox. } n += 7 - (day + n) % 7; //Advance to the next Sunday. cout << "Easter is on Sunday, "; if (n <= 31) { cout << "March " << n; } else { cout << "April " << n - 31; } cout << ", " << year << ".\n"; return EXIT_SUCCESS; }