Commit 7b137f3e authored by Alexandr Sitchenko's avatar Alexandr Sitchenko

delay

parent 5a6b49ee
...@@ -17,32 +17,41 @@ if (!ctype_digit($_GET['first']) || !ctype_digit($_GET['end'])) { ...@@ -17,32 +17,41 @@ if (!ctype_digit($_GET['first']) || !ctype_digit($_GET['end'])) {
if (strlen($_GET['first']) !== 6 || strlen($_GET['end']) !== 6) { if (strlen($_GET['first']) !== 6 || strlen($_GET['end']) !== 6) {
exit('You must enter parameters in format 000XXX!!'); exit('You must enter parameters in format 000XXX!!');
} }
if (((int)$_GET['end'] - (int)$_GET['first']) <= 0) { if (((int)$_GET['end'] - (int)$_GET['first']) <= 0) {
exit('The first parameter must be less than the second!'); exit('The first parameter must be less than the second!');
} }
$current = (int)$_GET['first']; $current = (int)$_GET['first'];
$num = $current; $num = $current;
$ticketsHappy = 0; $ticketsHappy = 0;
do { do {
$sum1 = 0; /*$sum1 = 0;
$sum2 = 0; $sum2 = 0;*/
$current = $num; $num = $current;
while ($current > 999) { $numbers []= intdiv($current, 1000);
$sum1 += $current % 10; $numbers []= $current%1000;
$current = (int)$current / 10; $sum = [];
} foreach($numbers as $key => $num) {
while ($current > 0) { $sumCurrent = 0;
$sum2 += $current % 10; while ($num > 0) {
$current = (int)$current / 10; $sumCurrent += $num % 10;
$num = intdiv($num,10);
}
if ($sumCurrent > 9) {
$sumCurrent = ($sumCurrent % 10) + intdiv($sumCurrent,10);
}
$sum []= $sumCurrent;
} }
if ($sum1 === $sum2) { if ($sum[0] === $sum[1]) {
//echo($current.'<br/>');
++$ticketsHappy; ++$ticketsHappy;
} }
unset($numbers,$sum,$sumCurrent);
//$happy($current); //$happy($current);
$stopLoop = ((int)$_GET['end'] - $num); $stopLoop = ($_GET['end'] - $current);
++$num; ++$current;
} while ($stopLoop); } while ($stopLoop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment