<?php error_reporting(-1);mb_internal_encoding('utf-8'); $total = 30;$skip = 5;$left = 30;$totalArray = range(1, $total); while ($left >= $skip) { for ($i = 1; $i <= count($totalArray); $i++) { if ($i % $skip == 0) { unset($totalArray[$i]); // $totalArray = array_values($totalArray); $left -= 1; } } $total = count($totalArray);} echo "Winners: ".implode(", ", $totalArray);
Standard input is empty
Winners: 1, 2, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 22, 23, 24, 25, 27, 28, 29, 30
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!