CS prerequisites

Here is a C function that calculates the Gregorian Easter. It's all right if you can't tell exactly what's going on, but please let me know if it looks like complete nonsense to you!
int Easter (int year) {
  int century;
  int skipped;
  int golden;
  int correction;
  int epact;
  int Paschal;
  int Sunday;
  int date;
  century = year / 100 + 1;
  skipped = 3 * century / 4;
  golden = year % 19 + 1;
  correction = (8 * century + 5) / 25;
  epact = (11 * golden + correction - skipped + 26) % 30 + 1;
  Paschal = 44 - epact;
  if (Paschal < 21) {
    Paschal += 30;}
  if (Paschal == 50 || Paschal == 49 && golden > 11) {
    Paschal --;}
  Sunday = 5 - (5 * year / 4 - skipped);
  date = Paschal + 7 - (Paschal - Sunday) % 7;
  return date;}

Go back to the MATH 112 homepage.
Valid HTML 4.01 Transitional

This web page was written between 1998 and 2003 by Toby Bartels. Toby reserves no legal rights to it.

The permanent URI of this web page is http://tobybartels.name/MATH112/2003/C/.