Checking for Leap Years

Some years in our (Gregorian) calendar are "leap years." In a leap year, February has a 29th day and the year overall has 366. Leap years let the calendar adjust for the fact that it takes the earth takes slightly over 365 days to revolve around the sun. The fact that it is approximately 365.25 days should mean that leap year should come every fourth year.

But, things are a bit more complicated than that because one revolution around the sun is almost but not quite 365.25 years, so leap years come slightly less often than once every four years. To figure out if a year (say, 1999) is a leap year, you need to test whether it is divisible evenly — that is, if there is no remainder after the division — by three different values.

A calendar year is a leap year if

(We aren't making this up.)

So, the year 2000 was a leap year (divisible evenly by 400, 100, and 4),1900 was not (divisible evenly by 100 and 4 but not by 400), 2012 was (divisible evenly by 4 but neither 100 nor 400), and 2015 wasn't (not divisible by 4).

  1. Consider the block sets below: they all say "leap year" if the year variable is a leap year and "normal year" otherwise. That is, they all work correctly, without any bugs. (The scripts are available in this snap program).
    These imeages need alt and title attributes. --MF
  2. Talk with Your Partner Discuss with others which version you prefer, and defend your answer.
    1. Which one is easiest to read?
    2. Which one would be easiest to rewrite from memory?
    3. In which one would it be the easiest to find a bug?
    4. Which one is the most beautiful?!