$n = trim(fgets(STDIN)); $count = 0; for($i=1;$i<=$n;$i++){ $count += $i; } echo $count;