Here is my solution;
I don't know if it can be done in an easier way but this is how I did it and it works:
func isLeap(year: Int) {
if year % 4 == 0 && year % 100 != 0 && year % 400 == 0 {
print("YES")
} else if year % 4 == 0 && year % 400 == 0 {
print("YES")
} else if year % 4 == 0 && year % 100 != 0 {
print("YES")
} else if year % 100 == 0 {
print("NO")
} else {
print("NO")
}
}
isLeap(year: 2000) // write here whatever number you want
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: