3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //$values = [ 16, 32, 48]; $values = range(16, 1000000, 2); function getCmmdc($values) { $num_values = count($values); $x = current($values); $y = next($values); for ($i = 1; $i < $num_values; $i ++) { $a = max($x, $y); $b = min($x, $y); $c= 1; do { $c = $a % $b; $gcf = $b; $a = $b; $b = $c; } while ($c != 0); $x = $gcf; $y = next($values); } //suma tuturor divizilorilor $sum = 0; for($i = 1; $i <= $gcf; $i ++){ $temp = $gcf % $i; if($temp == 0){ $sum += $i; } } return array($gcf, $sum); } var_dump(getCmmdc($values));
Output for 5.0.0 - 5.2.0, 7.0.0 - 7.1.0
array(2) { [0]=> int(2) [1]=> int(3) }
Output for 5.3.0 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/BBHMq on line 3
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/BBHMq on line 3
Process exited with code 255.
Output for 5.2.1 - 5.2.2
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /in/BBHMq on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Wrong parameter count for range() in /in/BBHMq on line 3 Warning: current(): Passed variable is not an array or object in /in/BBHMq on line 8 Warning: next(): Passed variable is not an array or object in /in/BBHMq on line 9 Notice: Undefined variable: gcf in /in/BBHMq on line 27 Notice: Undefined variable: gcf in /in/BBHMq on line 34 array(2) { [0]=> NULL [1]=> int(0) }
Output for 4.3.0 - 4.3.1
Warning: Wrong parameter count for range() in /in/BBHMq on line 3 Warning: current() [http://www.php.net/function.current]: Passed variable is not an array or object in /in/BBHMq on line 8 Warning: next() [http://www.php.net/function.next]: Passed variable is not an array or object in /in/BBHMq on line 9 Notice: Undefined variable: gcf in /in/BBHMq on line 27 Notice: Undefined variable: gcf in /in/BBHMq on line 34 array(2) { [0]=> NULL [1]=> int(0) }