3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isPrimeNumber($num) { $isPrime = 1; for ($i = 2; $i <= ($num/2); $i++) { if ($num % $i == 0){ $isPrime = 0; break; } } return ($isPrime==1 || $num==2)? 1 : 0; } function generateRightTriangle( $num ) { for ($i = 1, $rows = $num, $count = 2; $i <= $rows; $i++) { /* Print spaces in decreasing order of row */ for($j=$i; $j<$rows; $j++) { printf("%s"," "); } for ($j = 1; $j <= $i; $j++) { while( !isPrimeNumber($count) ){ $count++; } if ($i == 1) { printf(" %d",$count); } else if ($i == 2) { printf(" %-d",$count); } else if ($i == 3) { if ($count == 7) { printf(" %-d",$count); } else { printf(" %-2d",$count); } } else { printf(" %-d", $count); } $count++; } printf("\n"); } return true; } if (!generateRightTriangle(5)) { trigger_error("An error has occurred!"); }
Output for git.master, git.master_jit, rfc.property-hooks
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
58.01 ms | 401 KiB | 8 Q