Exercism: Go version of the 'Leap' exercise.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
334 B

6 years ago
  1. package leap
  2. const testVersion = 2
  3. // IsLeapYear receives an integer year value and returns a boolean indicating
  4. // whether the year is a leap year or not.
  5. func IsLeapYear(year int) bool {
  6. switch {
  7. case year%400 == 0:
  8. return true
  9. case year%100 == 0:
  10. return false
  11. case year%4 == 0:
  12. return true
  13. default:
  14. return false
  15. }
  16. }