Hello all!

I know this is a very elementary question. But please help me with this.
There can be many good algorithms to find prime numbers, but being a
starter, please correct my mistakes.
I want to take a number as input and find out if it is prime or otherwise.
My code is as follows:

# start
use strict;
use warnings;

print "\n\nEnter a number : " ;
my $x = 1, my $count = 0;
my $no = <>;
print "\n\nThe number is : $no";
if( $no<2 ){
print "\n\n$no is neither prime nor composite";
}
else{
while(($x!=$no)||$count<3){
if ($no%$x==0){
$count++;
}
$x++;
}
if ($count >=3 ){
print "\n\n$no is prime";
}
else{
print "\n\n$no is not prime";
}
}

print "\n\n";
system "pause";
# end
-- 
Love,
 Somu,
http://lose.yourself.mcommunity.biz
http://fidel.castro.peperonity.com

Reply via email to