Friday, February 29, 2008

Leap year

This day is a special day. For those whose age are multiples of 4 on this very day should know the significance of today. Today is the extra day that we added to February to correct the 365.25 days in a Earth year.

Thirty days have September,
April, June and November.
All the rest have thirty-one,
Except February the only one
Which Leap Years change
each fourth time
From twenty-eight to twenty-nine.
Century 100s don’t always leap,
each 400 years that leap we keep

The above poem actually describes which months of the year have 31 days and which have 30 days. February is the one that has either 28 or 29 days, depending on whether the year in question is a leap or common year. To determine if a year is a leap year or a common one, we carry out the following algorithm:

Let A = Year in question

EITHER A is divisible by 4
-------AND A is not divisible by 100 => leap year

OR A is divisible by 400 => leap year

ELSE, A => common year

To summarise, a leap year is a year which is divisible by 4 and not divisible by 100, or a year which is divisible by 400. A leap year would mean that the month of February will have 29 days instead of the usual 28.

2 comments :

Grey said...

Since 400 is divisible by 4, so your algorithm can be simplified to any year that's divisible by 4 is a leap year;

la papillion said...

Hi Grey,

Not really. There are 2 cases for leap year:

1) Divisible by 4 and not divisible by 100

2) Divisible by 400

E.g. 1700
1700 is divisible by 4, but 1700 is also divisible by 100, hence it's not a leap year.

E.g. 1600
1600 is divisible by 4, but 1600 is also divisible by 100, hence from (1) it's not a leap year. But 1600 is divisible by 400, it satisfies (2), hence it's a leap year.