Created
October 13, 2015 15:23
-
-
Save caelifer/b5e88e81ba20c39031bc to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"fmt" | |
) | |
func IsLeapYear(y int) bool { | |
return y%4 == 0 && y%100 != 0 || y%400 == 0 | |
} | |
func main() { | |
for _, i := range []int{-100, 1996, 1900, 2000, 2012} { | |
fmt.Println(i, IsLeapYear(i)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Live code - http://play.golang.org/p/0530VloSec