It is possible to caclulate every year's easter using simple
mathematical operations. Here is a code that does the trick: http://www.brlivre.org/c/easter.c
I found the math scheme in an american scientific issue, march
2001. The article about the calendars is very interesting.
Have fun...
--
Gustavo G. Rondina http://gustgr.freeshell.org 2 3353
Gustavo G. Rondina wrote: It is possible to caclulate every year's easter using simple mathematical operations. Here is a code that does the trick:
http://www.brlivre.org/c/easter.c
I found the math scheme in an american scientific issue, march 2001. The article about the calendars is very interesting.
cat easter.c
// Calculating Easter
#include <stdio.h>
#include <stdlib.h>
static const
char *month_array[] = {
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December" };
typedef struct Date {
int year;
int month;
int day;
} Date;
inline static
Date Date_create(int year, int month, int day) {
Date d;
d.year = year;
d.month = month;
d.day = day;
return d;
}
inline static
void Date_destroy(const Date* p) {
}
Date easter(int x) {
int a = x%19;
int b = x/100;
int c = x%100;
int h = (19*a + b - (b/4) - (8*b + 13)/25 + 15)%30;
int m = (a + 11*h)/319;
int l = (2*(b%4) + 2*(c/4) - c%4 - h + m + 32)%7;
int n = (h - m + l + 90)/25;
int p = (h - m + l + n + 19)%32;
return Date_create(x, n - 1, p);
}
int main(int argc, char *argv[]) {
int year; /* year to determine easter */
if (argc == 1) {
printf("Year: ");
scanf("%d", &year);
}
else
year = atoi(argv[1]);
Date d = easter(year);
printf("Easter %d is %s %d.\n",
d.year, month_array[d.month], d.day);
Date_destroy(&d);
return EXIT_SUCCESS;
}
gcc -Wall -std=c99 -pedantic -o easter easter.c ./easter 2004
Easter 2004 is April 11.
E. Robert Tisdale wrote: Gustavo G. Rondina wrote: It is possible to caclulate every year's easter using simple mathematical operations. Here is a code that does the trick:
<snip> char *month_array[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
Easter can never occur before March 22 or later than April 25. So why the
redundant code? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ron Adam |
last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone
here for a great programming language.
Below is my first Python program (not my first program) and I'd
apreciate any...
|
by: Kasp |
last post by:
Hi there,
I am trying to make an OLAP cube on a table having two columns (datetime,
Number_of_times_an_event_occured).
My dimension is time and I want to measure the Min and Max times an event...
|
by: Joe Bongiardina |
last post by:
What does the message "calculating...." mean in the lower left status area
of a form?
I have a form with no calculated, concatenated or lookup fields, yet it
displays this msg.
The form takes...
|
by: jlm |
last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time
(time taken off for Administrative, Annual, Sick, Compensation leave).
I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
|
by: Michael \(michka\) Kaplan [MS] |
last post by:
A little light humor... this "easter egg" was hidden deep in the Access 95
help system. I did not write it (I am not this creative and never was) and I
did not put it in the product (I was not on...
|
by: jimfortune |
last post by:
From:
http://groups-beta.google.com/group/comp.databases.ms-access/msg/769e67e3d0f97a90?hl=en&
Errata:
19 solar years = 2939.6018 days should be
19 solar years = 6939.6018 days
Easter...
|
by: Jorge |
last post by:
Hi
I wish You all an happy easter hollidays.
Jorge
|
by: kudos |
last post by:
Hi, a couple of months ago, I made a xmas chistmas "card" to this community(http://www.thescripts.com/forum/thread580722.html) Now its soon easter, and I hacked together something for easter as...
|
by: Schraalhans Keukenmeester |
last post by:
Happy Easter everyone,
Undoubtedly most of you know this already, but for the few who don't:
Even PHP has hidden some Easter Eggs for us to discover. It's just they
hid them quite well.
Have...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |