Illusory Follies Andrew Flanagan's Blog

24Mar/083

Easter Fun!

So -- on what date does Easter fall? Now YOU can impress your friends by using either of the Perl scripts below... Thanks to this site which supplied both Butcher's and Oudin's algorithm:

Butcher's Algorithm in Perl (1876 -- and the Perl code is almost that old too! šŸ™‚ )

sub GetEasterDate {
my($year)=@_;
my $a=$year%19;
my $b=int($year/100);
my $c=$year%100;
my $d=int($b/4);
my $e=$b%4;
my $f=int(($b+8)/25);
my $g=int(($b-$f+1)/3);
my $h=(19*$a+$b-$d-$g+15)%30;
my $i=int($c/4);
my $k=$c%4;
my $l=(32+2*$e+2*$i-$h-$k)%7;
my $m=int(($a+11*$h+22*$l)/451);
my $month=int(($h+$l-7*$m+114)/31);
my $p=($h+$l-7*$m+114)%31;
my $day=$p+1;
return($month."/".$day."/".$year."\n");
};

Oudin's Method in Perl (1940)

sub GetEasterDate {
my($year)=@_;
my $century = int($year / 100);
my $G = $year % 19;
my $K = int(($century - 17) / 25);
my $I = ($century - int($century / 4) - int(($century - $K) / 3) + 19 * $G + 15) % 30;
my $I = $I - (int($I / 28)) * (1 - int($I / 28) * int(29 / ($I + 1)) * int((21 - $G) / 11));
my $J = ($year + int($year / 4) + $I + 2 - $century + int($century / 4)) % 7;
my $L = $I - $J;
my $month = 3 + int(($L + 40) / 44);
my $day = $L + 28 - 31 * int($month / 4);
return($month."/".$day."/".$year."\n");
};

The second algorithm is more efficient. If I run 100,000 years of calculations I get about .035ms better performance over the "older" method.

For those of us who just "want the facts", here you go:

  • 4/12/2009
  • 4/4/2010
  • 4/24/2011
  • 4/8/2012
  • 3/31/2013
  • 4/20/2014
  • 4/5/2015
  • 3/27/2016
  • 4/16/2017
  • 4/1/2018
  • 4/21/2019
  • 4/12/2020
  • 4/4/2021
  • 4/17/2022
  • 4/9/2023
  • 3/31/2024
  • 4/20/2025
  • 4/5/2026
  • 3/28/2027
  • 4/16/2028
  • 4/1/2029
  • 4/21/2030
  • 4/13/2031
  • 3/28/2032
  • 4/17/2033
  • 4/9/2034
  • 3/25/2035
  • 4/13/2036
  • 4/5/2037
  • 4/25/2038
  • 4/10/2039
  • 4/1/2040
  • 4/21/2041
  • 4/6/2042
  • 3/29/2043
  • 4/17/2044
  • 4/9/2045
  • 3/25/2046
  • 4/14/2047
  • 4/5/2048
  • 4/18/2049

Oh, and if you're looking for a pattern, there is one: Every 5,700,000 years.

Thanks to yesterday's Slashdot post for getting me interested in this.

Comments (3) Trackbacks (0)
  1. And – of course – it doesn’t end there. The Russian (and some of the other Eastern) Orthodox hold to an “old calendar” way of calculating Easter, which yields a different result most years. It’s very different this year, for example.

    I’m afraid I don’t recall the competing algorithm.

  2. So, why do we base our timing of easter on the position of the moon? Isn’t that Pagan? Why do you think that the early church councils opted against the traditional Jewish passover timing? Isn’t that what the orthodox church opted for? Or, why don’t we base easter on the actual date in AD30? You should be able to identify the actual date for the Passover in the year 30.
    Schwiegervater

  3. Thanks.. a fun way to look at syntax I am not usually using.


Leave a comment

No trackbacks yet.