fork(1) download
  1. print "enter a number: ";
  2.  
  3. $in = <>;
  4. chomp $in;
  5.  
  6. print &prime($in);
  7. print "\n";
  8.  
  9. sub prime {
  10. for($i=2;$i<($_[0]/2+1);$i++) {
  11. if($_[0]%$i ==0) { return "not prime\n" }
  12. }
  13.  
  14. return "prime\n";
  15. }
Success #stdin #stdout 0s 4596KB
stdin
7
stdout
enter a number: prime