Python は,もう忘れたので Julia で(別のやり方で)やってみる。
function fizzbuzz(n)
fizzbuzz = string.(1:n)
[fizzbuzz[i] = "Fizz" for i in 3:3:n]
[fizzbuzz[i] = "Buzz" for i in 5:5:n]
[fizzbuzz[i] = "FizzBuzz" for i in 15:15:n]
return fizzbuzz
end
fizzbuzz(30)
30-element Vector{String}:
"1"
"2"
"Fizz"
"4"
"Buzz"
"Fizz"
"7"
"8"
"Fizz"
"Buzz"
"11"
"Fizz"
"13"
⋮
"19"
"Buzz"
"Fizz"
"22"
"23"
"Fizz"
"Buzz"
"26"
"Fizz"
"28"
"29"
"FizzBuzz"
あんまり,うれしくもないなあ...