How to calculate the Easter date for a given year using Gauss ' Algorithm | Python3 program for the above approach ; Function calculates and prints 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
import math NEW_LINE def gaussEaster ( Y ) : NEW_LINE INDENT A = Y % 19 NEW_LINE B = Y % 4 NEW_LINE C = Y % 7 NEW_LINE P = math . floor ( Y / 100 ) NEW_LINE Q = math . floor ( ( 13 + 8 * P ) / 25 ) NEW_LINE M = ( 15 - Q + P - P // 4 ) % 30 NEW_LINE N = ( 4 + P - P // 4 ) % 7 NEW_LINE D = ( 19 * A + M ) % 30 NEW_LINE E = ( 2 * B + 4 * C + 6 * D + N ) % 7 NEW_LINE days = ( 22 + D + E ) NEW_LINE if ( ( D == 29 ) and ( E == 6 ) ) : NEW_LINE INDENT print ( Y , " - 04-19" ) NEW_LINE return NEW_LINE DEDENT elif ( ( D == 28 ) and ( E == 6 ) ) : NEW_LINE INDENT print ( Y , " - 04-18" ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT if ( days > 31 ) : NEW_LINE INDENT print ( Y , " - 04 - " , ( days - 31 ) ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT print ( Y , " - 03 - " , days ) NEW_LINE return NEW_LINE DEDENT DEDENT DEDENT Y = 2020 NEW_LINE gaussEaster ( Y ) NEW_LINE