Prime Substrings by jonathan camacho

for(<>){chomp;for$l(1..length){for$j(0..-$l+length){
($r,$x)=(1,substr($_,$j,$l));for(2..sqrt($x)+1){if($x%$_==0&&$x!=$_){$r=0;last}}
print$x>1?$r:0}}print$/}

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

download

return to the top page