LoginSignup
2
0

More than 3 years have passed since last update.

富豪的プログラミング

Posted at

FizzBizz のEXCEL VBA でコメントにつけた下記のプログラムに、非効率という指摘を受けたのだけど、
これって、富豪的プログラミングなんだよね。
昔の愛読書であったbitで読んだ気がしたので検索したら、やはり bit 29(1), 36-37, 1997 だったよ。

Function FizzBuzz(Optional N = 100, Optional S = "")
    ReDim S(1 To N, 1 To 1)
    For I = 1 To N
        S(I, 1) = I
        If I Mod 3 = 0 Then S(I, 1) = "Fizz"
        If I Mod 5 = 0 Then S(I, 1) = "Buzz"
        If I Mod 15 = 0 Then S(I, 1) = "FizzBuzz"
    Next I
    FizzBuzz = S
End Function
2
0
0

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
2
0