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 3 years have passed since last update.

【php】合計が初めて1000を超えた時に、合計値と最後に足した値を出力せよ

Posted at

初めて合計値が1000を超えた時、

合計値を出力してください。
最後に足した値を出力してください。

<?php

$total = 0; 
$i = 0;

while($total<=1000){
   $i++;
   $total = $total + $i;
}

//計算結果
print "合計値:".$total."\n";

//forで回った回数
print "最後に足した数:".$i."\n";
?>

image.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?