@ 2018-10-26T14:34:44Z <?php
function repeatInt(int $val, int $min, int $max)
{
$validValueNum = $max - $min + 1;
$result = ($val %$validValueNum + $min) % $validValueNum;
if ($result< 0) {
$result= $validValueNum + $result;
}
return $min + $result;
}
// ??????
foreach (range(-10, 5) as $i) echo $i .'='. repeatInt($i, 2, 5) . PHP_EOL;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 -10=2
-9=3
-8=4
-7=5
-6=2
-5=3
-4=4
-3=5
-2=2
-1=3
0=4
1=5
2=2
3=3
4=4
5=5
Output for 5.6.0 - 5.6.40 Catchable fatal error: Argument 1 passed to repeatInt() must be an instance of int, integer given, called in /in/htUj9 on line 16 and defined in /in/htUj9 on line 2
Process exited with code 255 . preferences:dark mode live preview
141.28 ms | 401 KiB | 283 Q