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.

PHP基本構文『FizzBizz問題』

Posted at

FizzBuzz問題

1~20の数字に対して、3の倍数は「Fizz」5の倍数は「Buzz」15の倍数は「FizzBuzz」それ以外はその数字を出力してください。全て改行せよ。

記述したコード

for($i=0; $i<=20; $i=$i+1){
    if($i%3==0 && $i%5==0){
        echo 'FizzBuzz' . '<br>';
    }elseif($i%3==0){
        echo 'Fizz' . '<br>';
    }elseif($i%5==0){
        echo 'Buzz' . '<br>';
    }else{
        echo $i . '<br>';
    }
}

画面

スクリーンショット 2023-03-20 19.03.08.png

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