Easter by Hendrik (easter_test)

#easter formular (GAUSS)

def easter(y):
    a = y % 19
    b = y % 4
    c = y % 7
    d = ((y/100) * 8 + 13) / 25 - 2
    e = y/100 - y/400 - 2
    f = (15 + e - d) % 30
    g = (6 + e) % 7
    h = (19*a + f) % 30
    i = h
    if h == 29: i = 28
    if h == 28 and a > 10: i = 27
    j = (2*b + 4*c + 6*i + g) % 7

    #in days of march
    easter_day = i + j + 22
    m = easter_day/32 + 3
    d = easter_day % 32 + (m==4)

    #return day,month
    return (d,m)


for y in range(2001,3001):
    o = easter(y)
    print"%02d %s, %05d"%(o[0],["MARCH","APRIL"][o[1]-3],y)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page