<?php
$total = 8;
for ($i=1, $level=0; $total>=$level+$i; $i++) {
$level += $i;
$total -= $level;
echo "$i - $level\n";
}
echo "Остаток - $total";
PD9waHAKZXJyb3JfcmVwb3J0aW5nKC0xKTsKCiR0b3RhbCA9IDg7Cgpmb3IgKCRpPTEsICRsZXZlbD0wOyAkdG90YWw+PSRsZXZlbCskaTsgJGkrKykgewoJJGxldmVsICs9ICRpOwoJJHRvdGFsIC09ICRsZXZlbDsKCWVjaG8gIiRpIC0gJGxldmVsXG4iOwoJCn0KZWNobyAi0J7RgdGC0LDRgtC+0LogLSAkdG90YWwiOw==