LoginSignup
1
0

More than 1 year has passed since last update.

【PHP基礎⑬】ループ処理-3.カウントアップ

Last updated at Posted at 2022-06-21

[問題]  (参照:http://www.cc.kyoto-su.ac.jp/~mmina/bp1/hundredKnocksBasic.html)
整数値を入力させ、0から入力値まで数を1ずつ増やして表示するプログラムを作成しなさい。
なお、入力値に0以下の値を入力した場合は考慮しなくてもよい。

コード

$a = intval(fgets(STDIN));
for($m = 0; $m <= $a; $m++){
    echo "$m \n";
}

↓「7」と入力

結果

0 
1 
2 
3 
4 
5 
6 
7
1
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
1
0