TutorialEdge

Challenge 14 - Leap Years

Welcome, everyone to the discussion thread for the 14th Go challenge posted to the site :tada:

Feel free to show us how you solved the challenge by posting your solutions below!

package main

import "fmt"

func CheckLeapYear(year int) bool {
 // If a year is multiple of 400,  
  // then it is a leap year 
  if year % 400 == 0 {
  	return true; 
  }

  // Else If a year is muliplt of 100, 
  // then it is not a leap year 
  if year % 100 == 0 {
  	return false; 
  }

  // Else If a year is muliplt of 4, 
  // then it is a leap year 
  if year % 4 == 0 {
  	return true; 
  }
  return false; 
}

func main() {
  fmt.Println("Check Leap Year")

  year := 2020
  fmt.Println(CheckLeapYear(year))
}
func CheckLeapYear(year int) bool {
	if (year%4 == 0 && year%100 != 0) || year%400 == 0 {
		return true
	}
	return false
}