Did you know that the calculation of the anniversary of one of the most important festivals such as Easter for Catholics is not a trivial matter!
Like most of the Catholic feast of Easter is also a mixture of traditions from other religions, in fact the date of Easter has to do with the Jewish Passover (which is entirely different What! remember that Jews do not believe in coming of the Messiah! therefore would have no meaning for them to celebrate the Catholic Easter), which is based on the phases of the moon.
Obviously the motion of the moon is different from Earth and from year to year x date is different! To top it off, Easter is celebrated on the Sunday following the date x!
I say only that the calculation is not trivial at all and I will only refer you to the Wikipedia page where it is described the algorithm that I used! Do not try to explain why the algorithm is already complicated by his own! I used the algorithm of Gauss semlice which is much more than the other proposed in the wikipedia page and has the advantage of indicating the exact date!
here's the code:
- public class Easter
- {
- {/ / algorithm for Christian the calculation of Easter according to the Gregorian calendar (arithmetic method of Gauss) http://it.wikipedia.org/wiki/Calcolo_della_Pasqua # Metodo_aritmetico_di_Gauss
- int y = 2010 ; / / Gregorian year between 1583 and 2499
- final to int y = 19% ;
- final int b = y % 4 ;
- final int c = y % 7 ;
- int m = 24 ;
- int n = 5 ;
- / / assignment m and n according to the century of y
- if ( y> = 1583 & & y \u0026lt;= 1699)
- {
- m = 22 ;
- n = 2 ;
- }
- else if ( y >= 1700 && y <= 1799 )
- {
- m = 23 ;
- n = 3 ;
- }
- else if ( y >= 1800 && y <= 1899 )
- {
- m = 23 ;
- n = 4 ;
- }
- else if ( y >= 1900 && y <= 2099 )
- {
- m = 24 ;
- n = 5 ;
- }
- else if ( y >= 2100 && y <= 2199 )
- {
- m = 24 ;
- n = 6 ;
- }
- else if ( y >= 2200 && y <= 2299 )
- {
- m = 25 ;
- n = 0 ;
- }
- else if ( y >= 2300 && y <= 2399 )
- {
- m = 26 ;
- n = 1 ;
- }
- else if ( y >= 2400 && y <= 2499 )
- {
- m = 25 ;
- n = 1 ;
- }
- / / compute d and and
- int d = ( 19 * a + m ) % 30 ;
- int e = ( 2 * b + 4 * c + 6 * d + n ) % 7 ;
- / / calculate the days
- if (d + and \u0026lt; 10)
- {
- int March = d + and + 22 ; The Case March
- }
- else
- {
- int April = d + and - 9 ;
- if (April == 26 ) //eccezione 1 aprile
- System . out . println ( "La pasqua dell anno gregoriano " + y + " cade nel giorno 19 del mese di aprile" ) ;
- Else if ( April == 25 & & and == 6 & & to > 10 ) / / exception on April 2
- else / / generic case in April
- ;}
- }
- }
If you ended up here because they're looking for the date of Passover in a year x between the 1583 and 2499, I'll just ask that calculation.
0 comments:
Post a Comment