000005 Leap Years



Follow these 4 steps in order to decide if in any given year, February is 28 days or 29 days.


We start by defining natural numbers as numbers with no fractions in it, Example: 1, 2, 3, 4, 5, and so on.



Step 1: Divide the given year by 400. If this results in a natural number. February is 29 days. Ignore steps 2, 3, and 4.

Example: the year 2000.




Step 2: Divide the given year by 100. If this results in a natural number. February is 28 days. Ignore steps 3 and 4.

Example the year 1900.




Step 3: Divide the given year by 4. If this results in a natural number. February is 29 days. Ignore step 4.

Example the year 2020.




Step 4: If steps 1, 2, and 3 do not apply, February is 28 days.

Example the year 2023.


____________________________________________


I explain why I listed these 4 steps:


The reason for inserting one day every 4 years and omitting 3 days every 400 years has been because it takes the sun 365 days, 5 hours, 48 minutes, and 46 seconds to complete one revolution around the earth.



Therefore one year is equal to ( (365) days ) +  ( (5/24) day )  + ( ( (48) / (60*24) ) day ) + ( ( (46) / (60*60*24) ) day ) = ( (365) day ) + ( (0.2083333333) day ) + ( (0.0333333333) day ) + ( (0.0005324074) day ) = (365.242199074) day.



The 365.25-day year was very close to 365.242199074.

365.25 days - 365.242199074 days =

0.007800926 day per year difference =

0.187222224 hour per year difference = 

11.23333344 minutes per year difference =

674.0000064 seconds per year difference

0.007800926 * 400 = 3.1203704 day per 400 years



Therefore, this calendar would be off by +0.1203704 day per 400 years



+0.1203704 day per 400 years =

+0.000300926 day per year =

+0.007222224 hour per year =

+0.43333344 minute per year =

+26.0000064 seconds per year


____________________________________________


We program the above in Python:

# Acquire a year and convert it to an integer

givenYear=int(input(“Enter a year:  ”))

if givenYear % 400 == 0:

# Modulus (givenYear, 400)

print (“February is 29 days”)

elif givenYear % 100 == 0:

# Modulus (givenYear, 100)

print (“February is 28 days”)

elif givenYear % 4 == 0:

# Modulus (givenYear, 4)

print (“February is 29 days”)

else:

# else covers any and all other possibilites

print (“February is 28 days”)