From 1fb9df9b5bf6c36d444997afa3e8fcc817339887 Mon Sep 17 00:00:00 2001 From: hamza Date: Mon, 13 Jun 2022 11:10:19 +0100 Subject: [PATCH] add(subject):leap year --- subjects/leapyear/README.md | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 subjects/leapyear/README.md diff --git a/subjects/leapyear/README.md b/subjects/leapyear/README.md new file mode 100644 index 00000000..fbbd26d9 --- /dev/null +++ b/subjects/leapyear/README.md @@ -0,0 +1,39 @@ +## leap-year + +### Instructions + +Write a function named `isLeap(int)` that takes a year as a parameter and returns true if the year is a leap year and false otherwise. +- A leap year is a year divisible by 4, but not by 100. +- A leap year is also divisible by 400. +- If the number is not positive, return false + +### Expected function + +```go +func isLeap(year int)bool{ + // your code here +} +``` +### Usage + +```go +package main + +import "fmt" + +func main(){ + fmt.Println(isLeap(2020)) + fmt.Println(isLeap(2021)) + fmt.Println(isLeap(2022)) + fmt.Println(isLeap(-10)) +} +``` +and the output should be: + +``` console +$ go run . | cat -e +true$ +false$ +false$ +false$ +```