Browse Source

solved leap

master
Blaine Motsinger 1 year ago
parent
commit
8a69928c56
1 changed files with 25 additions and 12 deletions
  1. 25
    12
      go/leap/leap.go

+ 25
- 12
go/leap/leap.go View File

@@ -1,15 +1,28 @@
// This is a "stub" file. It's a little start on your solution.
// It's not a complete solution though; you have to write some code.

// Package leap should have a package comment that summarizes what it's about.
// https://golang.org/doc/effective_go.html#commentary
// Package for the leap exercise for the exercism.io go track
package leap

// IsLeapYear should have a comment documenting it.
func IsLeapYear(int) bool {
// Write some code here to pass the test suite.
// Then remove all the stock comments.
// They're here to help you get started but they only clutter a finished solution.
// If you leave them in, reviewers may protest!
return false
// IsLeapYear returns true if the year is a leap year, else returns false
func IsLeapYear(year int) bool {

var returnValue bool = false

// a leap year in the Gregorian calendar occurs:
// on every year that is evenly divisible by 4
if year%4 == 0 {

// except every year that is evenly divisible by 100
if year%100 == 0 {

// unless the year is also evenly divisible by 400
if year%400 == 0 {
returnValue = true
} else {
returnValue = false
}
} else {
returnValue = true
}
}

return returnValue
}

Loading…
Cancel
Save