-
-
Save neomatrixcode/6ebe72d611f27ee1d1d05be9972034f8 to your computer and use it in GitHub Desktop.
Fizzbuzz 4
This file contains 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
function fizzbuzz(n) | |
numbers = 1:n | |
# first we convert the numbers to strings | |
result = string.(numbers) | |
result[rem.(numbers, 3) .== 0] .= "Fizz" | |
result[rem.(numbers, 5) .== 0] .= "Buzz" | |
result[(rem.(numbers, 3) .== 0) .* (rem.(numbers, 5) .== 0)] .= "FizzBuzz" | |
return result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment