Created
October 27, 2014 16:21
-
-
Save briandowns/f0bf5035d452da0f700b to your computer and use it in GitHub Desktop.
Leap Year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
) | |
func isLeapYear(year int) bool { | |
switch { | |
case year % 4 != 0: return false | |
case year % 100 != 0: return true | |
case year % 400 != 0: return true | |
default: return false | |
} | |
} | |
func main() { | |
log.Println(isLeapYear(1984)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment