Skip to content

Instantly share code, notes, and snippets.

@neomatrixcode
Forked from niczky12/fizzbuzz_4.jl
Created January 25, 2021 20:55
Show Gist options
  • Save neomatrixcode/6ebe72d611f27ee1d1d05be9972034f8 to your computer and use it in GitHub Desktop.
Save neomatrixcode/6ebe72d611f27ee1d1d05be9972034f8 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