Unobtrusive Easter Calculator
Let's look at the code needed to create a calculator that does something a little more significant than just allowing our visitors to add or multiply two numbers together. What we are going to do is to create an Easter Day calculator where your visitors will enter the year and the calculator will tell them the day and month that Easter Day falls on in that year.
To be able to create an Easter calculator we first need to know how Easter is calculated. I found the following formula in a book called "The Calendar" by David Ewing Duncan. This particular formula has appeared in many other places before appearing in that book and has also appeared in lots of other places since.
Here's the code as it appears in the book.
b = year / 100
c = year % 100
d = b / 4
e = b % 4
f = (b + 8) / 25
g = (b - f + 1) / 3
h = (19 * a + b - d -g + 15) % 30
i = c / 4
k = c % 4
l = (32 + 2 * e + 2 * i - h - k) % 7
m = (a + 11 * h + 22 * l) / 451
Easter Month = (h + l - 7 * m + 114) / 31 [3 = March, 4 = April]
p = (h + l - 7 * m + 114) % 31
Easter date = p + 1