Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active February 6, 2024 15:05
Show Gist options
  • Save TheMuellenator/5343c658efdd46dc04522174fa4f0cd1 to your computer and use it in GitHub Desktop.
Save TheMuellenator/5343c658efdd46dc04522174fa4f0cd1 to your computer and use it in GitHub Desktop.
iOS repl.it - IF Else Challenge Solution
//Don't change this
var aYear = Int(readLine()!)!
func isLeap(year: Int) {
var leap = "NO"
//IF divisible by 4 with no remainders.
if year % 4 == 0 {
leap = "YES"
//Is leap year, unless:
}
if year % 100 == 0 {
leap = "NO"
//Is not leap year, unless:
}
if year % 400 == 0 {
leap = "YES"
//Is leap year.
}
print(leap)
}
//Don't change this
isLeap(year: aYear)
@abrahammella
Copy link

func isLeap(year: Int) {
    if year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) {
        print("YES")
    }
    else{
        print("NO")
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment