Prime Substrings by jonathan camacho

<?php
foreach(explode("\n",rtrim(stream_get_contents(STDIN)))as$n){for($l=1;$l<=strlen($n);$l++){for($off=0;$off<=strlen($n)-$l;$off++){$x=substr($n,$off,$l);$p=1;$y=2;while($y*$y<=$x&&$p){if($x%$y==0){$p=0;}$y++;}print$x>1?$p:0;}}print"\n";}
?>

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page