Lines 54
##### Keywords
date (2) easter (1) fuzzy math (1)
##### Permissions
Viewable by Everyone
Editable by All Siafoo Users

# Determine Date of Easter 0

 In Brief A completely opaque way to determine the date of easter for any year, using Gauss's algorithm.... more
 Language C
# 's
` 1/* 2**  EASTER.C - Determine the date of Easter for any given year 3** 4**  public domain by Ed Bernal 5*/ 6 7#include <stdlib.h> 8#include "datetime.h" 91011void easter(int year,int *easter_month, int *easter_day)12{13      int a,b,c,e,g,h,i,k,u,x,z;14      div_t f;1516      /*17      **  Gauss' famous algorithm (I don't know how or why it works,18      **  so there's no commenting)19      */2021      a = year % 19;22      f = div(year,100);23      b = f.quot;24      c = f.rem;25      f = div(b,4);26      z = f.quot;27      e = f.rem;28      f = div((8*b + 13),25);29      g = f.quot;30      f = div((19*a + b - z - g + 15),30);31      h = f.rem;32      f = div((a + 11*h),319);33      u = f.quot;34      f = div(c,4);35      i = f.quot;36      k = f.rem;37      f = div((2*e + 2*i - k - h + u + 32),7);38      x = f.rem;39      f = div((h-u+x+90),25);40      *easter_month = f.quot;41      f = div((h-u+x + *easter_month +19),32);42      *easter_day = f.rem;43}4445#ifdef TEST4647#include <stdio.h>4849main(int argc, char *argv[])50{51      int yr, mo, dy;5253      while (--argc)54      {55            yr = atoi(*++argv);56            if (100 > yr)57                  yr += 1900;58            easter(yr, &mo, &dy);59            printf("Easter in %d on %d/%d\n", yr, mo, dy);60      }61      return 0;62}6364#endif /* TEST */`

A completely opaque way to determine the date of easter for any year, using Gauss's algorithm.

Define TEST for the compiler to get a test main() function.

Incidentally, Easter officially falls on the first Sunday after the 14th day of the lunar month that starts (has a full moon) after March 21st. Or something.