How to calculate the Easter date for a given year using Gauss ' Algorithm | Function calculates and prlets easter date for given year Y ; All calculations done on the basis of Gauss Easter Algorithm ; A corner case , when D is 29 ; Another corner case , when D is 28 ; If days > 31 , move to April April = 4 th Month ; Otherwise , stay on March March = 3 rd Month ; Driver Code
function gaussEaster ( Y ) { let A , B , C , P , Q , M , N , D , E ; A = Y % 19 ; B = Y % 4 ; C = Y % 7 ; P = Math . floor ( Y / 100 ) ; Q = Math . floor ( ( 13 + 8 * P ) / 25 ) ; M = ( 15 - Q + P - P / 4 ) % 30 ; N = ( 4 + P - P / 4 ) % 7 ; D = ( 19 * A + M ) % 30 ; E = ( 2 * B + 4 * C + 6 * D + N ) % 7 ; let days = ( 22 + D + E ) ; if ( ( D == 29 ) && ( E == 6 ) ) { document . write ( Y + " " + " " ) ; return ; } else if ( ( D == 28 ) && ( E == 6 ) ) { document . write ( Y + " " + " " ) ; return ; } else { if ( days > 31 ) { document . write ( Y + " " + ( days - 31 ) ) ; return ; } else { document . write ( Y + " " + days ) ; return ; } } } let Y = 2020 ; gaussEaster ( Y ) ;