# Code Kata: Is it a leap year?

- - on
- in Code -

You are given a year, determine if itâ€™s a leap year. A leap year is a year containing an extra day. It has 366 days instead of the normal 365 days. The extra day is added in February, which has 29 days instead of the normal 28 days. Leap years occur every 4 years. 2012 is a leap year and so is 2016. Except that every 100 years special rules apply. Years that are divisible by 100 are not leap years if they are not divisible by 400. For example 1900 was not a leap year, but 2000 was. Print Leap year! or Not a leap year! depending on the case.

func isALeapYear(year: Int) -> String { if (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)) { return "Leap year!" } else { return "Not a leap year!" } } print(isALeapYear(1900)) print(isALeapYear(2000)) print(isALeapYear(2012)) print(isALeapYear(2016))