October 2006
Intermediate to advanced
888 pages
16h 55m
English
Traditionally this holiday is one of the most difficult to compute because it is tied to the lunar cycle. The lunar month does not go evenly into the solar year, and thus anything based on the moon can be expected to vary from year to year.
The algorithm we present here is a well-known one that has made the rounds. We have seen it coded in BASIC, Pascal, and C. We now present it to you in Ruby:
def easter(year) c = year/100 n = year - 19*(year/19) k = (c-17)/25 i = c - c/4 - (c-k)/3 + 19*n + 15 i = i - 30*(i/30) i = i - (i/28)*(1 -(i/28)*(29/(i+1))*((21-n)/11)) j = year + year/4 + i + 2 - c + c/4 j = j - 7*(j/7) l = i - j month = 3 + (l+40)/44 day = l + 28 - 31*(month/4) [month, day] end date = easter 2001 ...
Read now
Unlock full access