3v4l.org

run code in 300+ PHP versions simultaneously
<?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); } getCmmdc($values);
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0, 7.0.0 - 7.0.9, 7.0.11, 7.0.13, 7.0.16 - 7.0.33, 7.1.0 - 7.1.1, 7.1.3 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13, 7.4.0 - 7.4.1, 8.1.28, 8.2.17 - 8.2.18, 8.3.3 - 8.3.4, 8.3.6 - 8.3.7
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Output for 5.6.32, 7.0.10, 7.0.12, 7.0.14 - 7.0.15, 7.1.2

Process exited with code 137.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.31, 5.6.33 - 5.6.40
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/u1bMa on line 3
Process exited with code 255.
Output for 5.2.2, 5.2.6 - 5.2.17
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 71 bytes) in /in/u1bMa on line 3
Process exited with code 255.
Output for 5.2.1, 5.2.3 - 5.2.5
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 24 bytes) in /in/u1bMa on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Warning: Wrong parameter count for range() in /in/u1bMa on line 3 Warning: current(): Passed variable is not an array or object in /in/u1bMa on line 8 Warning: next(): Passed variable is not an array or object in /in/u1bMa on line 9 Notice: Undefined variable: gcf in /in/u1bMa on line 27 Notice: Undefined variable: gcf in /in/u1bMa on line 34
Output for 4.3.0 - 4.3.1
Warning: Wrong parameter count for range() in /in/u1bMa on line 3 Warning: current() [http://www.php.net/function.current]: Passed variable is not an array or object in /in/u1bMa on line 8 Warning: next() [http://www.php.net/function.next]: Passed variable is not an array or object in /in/u1bMa on line 9 Notice: Undefined variable: gcf in /in/u1bMa on line 27 Notice: Undefined variable: gcf in /in/u1bMa on line 34

preferences:
221.45 ms | 402 KiB | 333 Q