fork download
  1. <?php
  2.  
  3. $total = 8;
  4.  
  5. for ($i=1, $level=0; $total>=$level+$i; $i++) {
  6. $level += $i;
  7. $total -= $level;
  8. echo "$i - $level\n";
  9.  
  10. }
  11. echo "Остаток - $total";
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
1 - 1
2 - 3
Остаток - 4