Easter

Calculate the date of Easter, accurate from 1900 to 2368 inclusive, with Python

Easter is celebrated on the first Sunday after the first full moon on or after 21 March.

#!/usr/bin/python3
import sys
y=int(sys.argv[1])
c=y//100;n=y-19*(y//19);k=(c-17)//25;i=c-c//4-(c-k)//3+19*n+15
i=i-30*(i//30);i=i-(i//28)*(1-(i//28)*(29//(i+1))*((21-n)//11))
j=y+y//4+i+2-c+c//4;j=j-7*(j//7);l=i-j;m=3+(l+40)//44;d=l+28-31*(m//4)
print(f"{y:04d}-{m:02d}-{d:02d}")

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply