-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Looks great. Everything is almost here only easter is missing.
Easter can be a little tricky. Here is a simple example in C.
/* Source: https://www.rmg.co.uk/stories/topics/when-easter */
#include <stdio.h>
void easter(int y, int *m, int *d) {
*d = 225 - 11 * (y % 19);
while (*d > 50)
*d -= 30;
if (*d > 48)
--*d;
*d = *d + 7 - (y + y/4 + *d + 1) % 7;
if (*d > 31) {
*m = 4;
*d -= 31;
} else {
*m = 3;
}
return 0;
}
int main( void ) {
int year, day, month;
for (year=1998; year<2100; year++) { // algorithm does not work after 2099
easter(year,&month,&day);
printf("%d-%02d-%02d\n", year, month, day);
}
return 0;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels