Given an integer Y, denoting a year, as input, the task is to find the date of Easter for that year.
Input: Y = 2020
In 2020, Easter was on 12 April
Hence, Easter date will be 2020-04-12
Input: Y = 1991
In 1991, Easter was on 30 March
Hence, Easter date will be 1991-03-30
Approach: Gauss Easter Algorithm is used to easily calculate the date of Easter for a year. This algorithm was first thought of by Carl Friedrich Gauss. There is no proper explanation on how Gauss landed up with this algorithm but the implementation of this algorithm has proved to be very accurate.
A detailed explanation of the Gauss Easter Algorithm is as follows:
- First, calculate the location of the year Y in the Metonic cycle.
A = Y mod 19
- Now, find the number of leap days according to Julian calendar.
B = Y mod 4
- Then, let’s take into account that the non-leap year is one day longer than 52 weeks.
C = Y mod 7
- M depends on the century of year Y. For 19th century, M = 23. For 21st century, M = 24 and so on.
It is calculated using following relations:
P = floor (Y / 100)
Q = ((13 + 8 * P) / 25)
M = (15 – Q + P – (P / 4)) mod 30
- The difference between the number of leap days between the Julian and the Gregorian calendar is given by:
N = (4 + P – (P / 4)) mod 7
- The number of days to be added to March 21 to find the date of the Paschal Full Moon is given by:
D = (19*A + M) mod 30
- And, the number of days from the Paschal full moon to the next Sunday is given by:
E = (N + 2*B + 4*C + 6*D) mod 7
- Therefore, using D ans E, the date of Easter Sunday is going to be March (22 + D + E). If this number comes out to be greater than 31, then we move to April.
- Now the lunar month is not exactly 30 days but a little less than 30 days. So to nullify this inconsistency, following cases are followed:
if (D == 29) and (E == 6)
return “April 19”
else if (D == 28) and (E == 6)
return “April 18”
Below is the implementation of the above approach:
Time complexity: O(1)
Auxiliary Space: O(1)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- C program to check if a given year is leap year using Conditional operator
- Program to check if a given year is leap year
- Find the day number in the current year for the given date
- Date after adding given number of days to the given date
- Program to calculate Resistance using given color code in circuits
- Count of Leap Years in a given year range
- C program to display month by month calendar for a given year
- Program to calculate the value of sin(x) and cos(x) using Expansion
- Calculate nCr using Pascal's Triangle
- Program to calculate the number of odd days in given number of years
- Calculate area of pentagon with given diagonal
- Program to calculate area and perimeter of a rhombus whose diagonals are given
- Calculate the loss incurred in selling the given items at discounted price
- Program to calculate angle on circumference subtended by the chord when the central angle subtended by the chord is given
- Calculate MDAS Factorial of given number
- Program to calculate area of a rhombus whose one side and diagonal are given
- Calculate the frequency of each word in the given string
- Calculate Sum of ratio of special characters to length of substrings of the given string
- Calculate the Square of Euclidean Distance Traveled based on given conditions
- Program to find century for a year
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : bansal_rtk_