0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ただただシンプルに FizzBuzz する

Last updated at Posted at 2023-02-11

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"

あんまり,うれしくもないなあ...

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?