Hello, im in the process of teaching myself PERL from a book. I have a background in VB, so it is going fairly easy for me, so far.... As one of the excercises in the book, there is a program i had to write to find prime numbers, but i cannot figure out why it wont run properly? I would greatly appreciate your help on this. Im trying to do the best i can with just this book i have, but i seem to constantly hit a roadblock.
heres the code, please examine, yeah, its pathetic)
#!/usr/bin/perl -w
$maxprimes=20;
$value=1;
$count= 0;
While($count < $maxprimes) {
$value++;
$composite=0;
OUTER: for ($i=2; $i<$value; $i++) {
for($j=$i+; $j<$value; $j++) {
if (($j*$i)==$value) {
$composite = 1;
last OUTER;
}
}
}
if (! $composite) {
$count++;
print "$value is prime\n";
}
}
#!/usr/bin/perl -w
$maxprimes=20;
$value=1;
$count= 0;
While($count < $maxprimes) {
$value++;
$composite=0;
OUTER: for ($i=2; $i<$value; $i++) {
for($j=$i+; $j<$value; $j++) {
if (($j*$i)==$value) {
$composite = 1;
last OUTER;
}
}
}
if (! $composite) {
$count++;
print "$value is prime\n";
}
}