Knaph

The Year, Exactly3 of 3

Is It a Leap Year?

Read a year from standard input and print True if it is a leap year in the Gregorian calendar, or False if it isn't.

The rule:

  • divisible by 400: a leap year
  • otherwise, divisible by 100: not a leap year
  • otherwise, divisible by 4: a leap year
  • otherwise: not a leap year

For example, 2024 prints True, 1900 prints False and 2000 prints True.

Sign in to try this exercise.