< previous page page_156 next page >

Page 156
Listing 6.12 epact_gregorian_obeirne_1 ()
/* epactgol.c


   +-------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham.  |
   |         All rights reserved.              |
   +-------------------------------------------+


   Routine for Gregorian epact from T. H. O'Beirne, "Puzzles and
   Paradoxes". This is the first of two alternative procedures given.


   INPUTS:
   1. year, type int, the year in the Gregorian calendar for which
      the value of epact is desired. Valid values are 1583 to INT_MAX.


   OUTPUTS:
   1. Returned by routine, type int, the value of epact for the input
      year. Valid values are 1 through 30.


   NOTES:
   1. This routine is based on Table 10a, page 180 of O'Beirne, and is
      the set of 'upper rules' which emphasizes explanation rather than
      simplicity of computation. The value of epact is calculated as
      part of the solution of Easter date, and this routine is essentially
      a form of the routine 'easter_gregorian_obeirne_1 ()', truncated
      at the point where epact is found.


   2. O'Beirne states (page 178) that the algorithm is based on a procedure
      which was first given in "Nature" in 1876 by an anonymous New York
      correspondent.


   3. This routine returns a value of zero for years less than 1583.
      No other validation is performed, and no warning is issued in this
      case.
*/


int epact_gregorian_obeirne_1 (int year)
{
   int a, b, d, g, h, epact;


   if (year < 1583)
      return (0);


   a = year % 19;
   b = year / 100;
   d = b / 4;
   g = ((8 * b) + 13) / 25;
   h = ((19 * a) + b - d - g + 15) % 30;
   epact = 23 - h;


   if (epact > 0)
      return (epact);
   else
      return (epact + 30);
}


 
< previous page page_156 next page >