# Gaussian algorithm for calculating Easter Sunday

Carl Friedrich Gauss (* 1777 - † 1855) was a prolific German mathematician and physicist who left an indelible mark on many fields of human knowledge. He had a mind for numbers and was said to be able to calculate a comet's trajectory within the span of an hour, a feat that usually took others in his field several days to perform. He also left his mark as a computist in the science of calendar calculations, specifically computus, otherwise known as the calculation of Easter Sunday. According to legend, he had originally restricted this attempt to simply finding out the exact day of his birth. The story goes that he had learned from his mother that his birthday was eight days before the feast of the Ascension of the Lord, which would have been 39 days after Easter Sunday in the year 1777. Unfortunately, he didn’t want to publish the full procedure he used to achieve the result, having limited his publication to the barest formulas and proofs under the pretext that “a finished house should be visible without the scaffolding”. This leaves us today only able to guess as to how the resulting algorithm came about. He published the result of his work at the age of 23 (he already had his doctorate) in the professional journal “Monatliche Correspondenz” in the August issue of 1800. In the resulting formula, he accomplished his calculation without the use of epacts, dominical letters and the like. Below I will try to reconstruct the assembly of that final formula.

For starters, we’ll need to make a simple table of ecclesiastical (paschal) full moons depending on the Golden Number in the Julian calendar. Now, the first ecclesiastical full moon can occur no earlier than 21 March (Golden Number 16) and absolutely no later than 18 April (Golden Number 8). If you recall, the Sunday following the first full moon of spring (ecclesiastical full moon) is Easter Sunday. Looking at the chart below, you’ll see that the penultimate column always contains the March date of that full moon (if the number exceeds 31 March with a number like 32, that would 1, likewise 33 is 2 April, and so on).

Golden number | Ecclesiastical full moon | March | Days from March 21 |
---|---|---|---|

1 | Apr 5 | 36 | 15 |

2 | Mar 25 | 25 | 4 |

3 | Apr 13 | 44 | 23 |

4 | Apr 2 | 33 | 12 |

5 | Mar 22 | 22 | 1 |

6 | Apr 10 | 41 | 20 |

7 | Mar 30 | 30 | 9 |

8 | Apr 18 | 49 | 28 |

9 | Apr 7 | 38 | 17 |

10 | Mar 27 | 27 | 6 |

11 | Apr 15 | 46 | 25 |

12 | Apr 4 | 35 | 14 |

13 | Mar 24 | 24 | 3 |

14 | Apr 12 | 43 | 22 |

15 | Apr 1 | 32 | 11 |

16 | Mar 21 | 21 | 0 |

17 | Apr 9 | 40 | 19 |

18 | Mar 29 | 29 | 8 |

19 | Apr 17 | 48 | 27 |

The Golden number is calculated by dividing the year in question by 19, taking the remainder, and adding 1 to it.
The value in the final column regularly decreases by 11 as opposed to the previous row. If we get a number less than 21, we add 30.
We keep repeating this until we get to the end of the table.
If we subtract 21 from any value in the final column of the table, we get the number of days between the ecclesiastical full moon and 21 March,
the beginning of spring as set in place by the church (see the last column).
In the formula below, this difference is denoted by the letter **d**, its value is then obtained using a relatively simple calculation.
Let the letter **a** denote only the remainder after dividing the year by the number 19, and since it’s mathematically impossible for the remainder to be 19 or larger, it takes values from 0 to 18:

**a = year % 19**

**d = (19 × a + 15) % 30**

The number 15 is a constant for the Julian calendar. The operator '%' denotes the remainder is the only thing kept after division (e.g. 23 % 5 = 3).

We define other auxiliary variables: **b** is a cycle of leap years and takes values from 0 to 3.
The letter **c** is a cycle of alternating days of the week, and it takes its values from 0 to 6.
Now we can calculate how many days from the ecclesiastical (pascal) full moon that Easter Sunday occurs on.
Let the letter **e** denote this number of days reduced by 1.

**b = year % 4**

**c = year % 7**

**e = (2×b + 4×c + 6×d + 6) % 7**

The formula **(2 × b + 4 × c) % 7** calculates the day of the week for the selected day.
The equivalent to this is a dominical letter (in the case of a leap year, only the latter applies).
The resulting numbers 0, 1, ..., 6 can then be uniquely assigned the Sunday letters C, D, ..., B.
We will use this to determine the day of the week for 22 March. The number 0 corresponds to Monday, 1 is Sunday, and all the way up to 6 is Tuesday.
Since we are interested in the number of days from Sunday, it is advisable to choose Sunday on the number 0, the added constant 6 will help.
The results can be shown in the following small table:

(2×b+4×c+6)%7 | 22nd of March |
---|---|

6 | Monday |

5 | Tuesday |

4 | Wednesday |

3 | Thursday |

2 | Friday |

1 | Saturday |

0 | Sunday |

If the day of the week on 22 March had not changed in different years, this formula would have been useless. However, since it changes, the value of the expression decreases by 1 each subsequent non-leap year (for example, if it was Monday on 22 March in a given year and Tuesday on the same leap year, then it decreases by 2 in the leap year).

The expression **+ 6 × d** replaces the expression **−d**, thus avoiding a negative result in parentheses.
This adjustment can be made, because the final result is still only the remainder after dividing by seven, from which we can add seven times any natural number.
In this case, we add **7 × d** (then **6 × d = −d + 7 × d**). The sought date of Easter Sunday is then easy to get.
As of 22 March, we add the number of days to the ecclesiastical full moon (**d**) to the number of days from the ecclesiastical full moon
until Easter Sunday (e is already reduced by 1 so we add it to 22 March 22, not to 21 March).

**Easter Sunday (March) = d + e + 22**

The result is always a March date for Easter Sunday. If we get a number greater than 31, it is necessary to subtract 31 and the result is the April date. Therefore, the following applies to the April date:

**Easter Sunday (April) = d + e - 9**

All of the formulas and the table used so far apply only to the Julian calendar!

In the Gregorian calendar, the situation is somewhat more complicated due to the solar and lunar correction (see the description of the Easter Sunday calculation). The date of the ecclesiastical full moon then depends on the century. For Golden Number 1, we get this table (a more extensive similar table can be found on the Golden Numbers Series page):

Years | Lunar Correction | Solar Correction | Full moon date |
---|---|---|---|

Up to 1582 | April 5 | ||

1583-1599 | -3 | +10 | April 12 |

1600-1699 | 0 | 0 | April 12 |

1700-1799 | 0 | +1 | April 13 |

1800-1899 | -1 | +1 | April 13 |

1900-1999 | 0 | +1 | April 14 |

2000-2099 | 0 | 0 | April 14 |

2100-2199 | -1 | +1 | April 14 |

2200-2299 | 0 | +1 | April 15 |

2300-2399 | 0 | +1 | April 16 |

2400-2499 | -1 | 0 | April 15 |

2500-2599 | 0 | +1 | April 16 |

2600-2699 | 0 | +1 | April 17 |

2700-2799 | -1 | +1 | April 17 |

2800-2899 | 0 | 0 | April 17 |

2900-2999 | 0 | +1 | April 18 |

Due to this complication, the values of the constants used in the formulae for the Julian calendar change. First, though, we need to define auxiliary variables (division here should only be done with whole numbers and without any consideration for the remainder):

**k = year / 100**

**p = (13 + 8 × k) / 25**

**q = k / 4**

The expression itself **(k - p - q)** shows the difference between the first ecclesiastical full moon of spring in the Julian and Gregorian calendars (see the table above).
This expression is used to calculate the value of the constant M (whereas in the Julian calendar, the constant is always 15).

**M = (15 + k - p - q) % 30**

This calculation of the constant for determining the ecclesiastical full moon caused the greatest difficulty.
This problem wasn’t likely due to the author's insufficient mathematical acumen, but rather due to him having the wrong initial information.
The monthly correction usually changes after 300 years, but once every 2,500 years it changes after 400 years.
The original version was **p = k / 3**, but later it was found that the formula gives poor results for the year 4200, and the mistake only grows over time.
It was several years later that Gauss would correct the calculation.

It was much simpler to adjust the constant to take account of the solar correction (denoted by **N**),
where the expression **(k - q - 2)** which shows the difference between the calendars in days.

**N = (4 + k - q) % 7**

We will display both constants depending on the century in a simple table below.

Years | M | N |
---|---|---|

1583-1599 | 22 | 2 |

1600-1699 | 22 | 2 |

1700-1799 | 23 | 3 |

1800-1899 | 23 | 4 |

1900-1999 | 24 | 5 |

2000-2099 | 24 | 5 |

2100-2199 | 24 | 6 |

2200-2299 | 25 | 0 |

2300-2399 | 26 | 1 |

2400-2499 | 25 | 1 |

2500-2599 | 26 | 2 |

2600-2699 | 27 | 3 |

2700-2799 | 27 | 4 |

2800-2899 | 27 | 4 |

2900-2999 | 28 | 5 |

The calculation of the remainder after division (in the case of the constant M, it’s after dividing by 30, and in the case of the constant N it’s from the remainder after dividing by 7) is unnecessary, because in the formulas for d and e, this operation is performed again. However, Gauss did do the same in his progress. The modified formulae for the Gregorian calendar then looked like this (the other formulas for a, b and c are the same as for the Julian calendar):

**d = (19 × a + M) % 30**

**e = (2 × b + 4 × c + 6 × d + N) % 7**

**Easter Sunday (March) = d + e + 22**or:

**Easter Sunday (April) = d + e - 9**

But this is not the end of our calculation. We must not forget that the latest possible date for Easter Sunday is 25 April.
The algorithm shown above generates 26 April for some years. These are, for example, the years 1609, 1981 and 2076.
These are the years with epact 24 and the Dominical letter of D. It’s necessary to add an exception.
In the cases where **d = 29** and **e = 6** at the same time, then Easter Sunday is a week earlier, on 19 April.
Another exception is due to the special treatment of epact 25 (in this case, Easter Sunday is a week earlier than the latest possible date).
This applies, for example, to the years 1954 and 2049. These are the years with epact 25, Sunday letter C and Golden numbers greater than 11 (see the following for more information).
For these, it’s necessary to add another complicated condition: if **d = 28**, **e = 6** and **a > 10**,
and if all of these conditions are true at the same time, then Easter Sunday is on 18 April
(if you remember, a is actually the Golden Number reduced by 1; initially this last part of the condition was even more complicated: **(11 × M + 11) % 30 < 19**).

a = year % 19 |

b = year % 4 |

c = year % 7 |

k = year / 100 |

p = (13 + 8 * k) / 25 |

q = k / 4 |

M = (15 − p + k − q) % 30 |

N = (4 + k − q) % 7 |

d = (19 * a + M) % 30 |

e = (2 * b + 4 * c + 6 * d + N) % 7 |

if (d + e + 22) is less than 32, then Easter Sunday is (d + e + 22) of March |

if d is equal to 29 and at the same time e is equal to 6, then Easter Sunday is April 19 |

if d is equal to 28 and at the same time e is equal to 6 and at the same time 'a' is greater than 10, then Easter Sunday is 18 April |

otherwise it is Easter Sunday (d + e - 9) of April |

Thanks to all of this, Gauss finally discovered that in 1777, Easter Sunday was 30 March. The Feast of the Ascension dates are 39 days after Easter, and since he was born eight days before those feasts, he could then easily calculate his birthdate as 30 April, 1777.

## Attempt to improve the algorithm

Interestingly, Gauss used this formula to determine the day of the week for the selected day: **(2 × b + 4 × c) % 7**,
which requires two more previous calculations to determine b and c with the formula, **(year + year / 4) % 7**.
Although the numbers for individual days of the week gradually increase, we can adjust the formula for calculating e based on this behaviour.
The result then looks like this:

**bc = (year + year / 4) % 7**

**e = (35 + N - bc - d) % 7**

Constant 35 only prevents the possibility of a negative number in parentheses; any larger number divisible by 7 can be used. Or, you can use the same method as used by Gauss and add seven times the subtracted expression, which causes the formula for e to looks like this:

**e = (N + 6 × (bc + d)) % 7**

Rows for calculating b and c are no longer needed, so we save a row. We can also simplify the conditions. In the Gregorian calendar, the most recent ecclesiastical full moons are 'shrunk', see the table:

d | epact | Ecclesiastical full moon |
---|---|---|

26 | 27 | April 16 |

27 | 26 | April 17 |

28 | 25/25 | April 17/18 |

29 | 24 | April 18 |

After calculating **d** (which is the number of days between the cyclic full moon and March 21), we can adjust its value as follows:

or if d is equal to 28 and at the same time 'a' is greater than 10, then d = d - 1

This treated epact 24 and special epact 25. No further conditions are needed, the other lines remain unchanged. This abbreviated algorithm, of course, then gives the same results as the original Gaussian algorithm.

a = year % 19 |

bc = (year + year / 4 ) % 7 |

k = year / 100 |

p = (13 + 8 * k) / 25 |

q = k / 4 |

M = 15 − p + k − q |

N = 4 + k − q |

d = (19 * a + M) % 30 |

if d is equal to 28 and at the same time 'a' is greater than 10, then d = d - 1 |

if d is equal to 29, then d = d - 1 |

e = (35 + N - bc - d) % 7 |

if (d + e + 22) is less than 32, then Easter Sunday is (d + e + 22) of March |

otherwise it is Easter Sunday (d + e - 9) of April |