Skip to content

Instantly share code, notes, and snippets.

@niczky12
Last active January 25, 2021 20:55
Show Gist options
  • Save niczky12/120c069f52762ee05e908c49f24f1199 to your computer and use it in GitHub Desktop.
Save niczky12/120c069f52762ee05e908c49f24f1199 to your computer and use it in GitHub Desktop.
Fizzbuzz 4
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