Advertisement
wpl36

Untitled

Aug 7th, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. func isLeapYear(_ year: Int) -> Bool {
  2.  
  3. var divBy4:Bool = false
  4. var divBy100:Bool = false
  5. var divBy400:Bool = false
  6.  
  7.  
  8. if number(year, isDivisibleBy: 4) {
  9. return divBy4 == true
  10. } else {
  11. return divBy4 == false
  12. }
  13.  
  14. if number(year, isDivisibleBy: 100) {
  15. return divBy100 == true
  16. } else {
  17. return divBy100 == false
  18. }
  19.  
  20. if number(year, isDivisibleBy: 400) {
  21. return divBy400 == true } else {
  22. return divBy400 == false
  23. }
  24.  
  25. if divBy4 && !divBy100 && divBy400 {
  26. return true
  27. } else {
  28. return false
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement