Created
June 21, 2018 12:09
-
-
Save lanserxt/3e6d9a885a2f715d8e12689d07f25c04 to your computer and use it in GitHub Desktop.
FizzBuzz test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fizzBuzz(number: Int) -> String { | |
if number % 3 == 0 && number % 5 == 0 { | |
return "Fizz Buzz" | |
} else { | |
if number % 3 == 0 { | |
return "Fizz" | |
} else { | |
if number % 5 == 0 { | |
return "Buzz" | |
} else { | |
return String(number) | |
} | |
} | |
} | |
} | |
print(fizzBuzz(number: 3)) | |
print(fizzBuzz(number: 5)) | |
print(fizzBuzz(number: 15)) | |
print(fizzBuzz(number: 16)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment