Hello,
I am trying to get this code to print all prime numbers, this code was psudo code and i am trying to translate it into perl, but it seems that i have some technical difficulties as this is my first program on perl
OS: Windows Xp / Intel x86
Error: Wierd Numbers coming out!
Comment: This is not my an H.W
I am trying to get this code to print all prime numbers, this code was psudo code and i am trying to translate it into perl, but it seems that i have some technical difficulties as this is my first program on perl
OS: Windows Xp / Intel x86
Error: Wierd Numbers coming out!
Comment: This is not my an H.W
Code:
#!/usr/bin/perl -w
$n = 10;
@$A[300] = "Initialize..";
for($p=2;$p<$n;$p++){
@$A[$p] = $p;
}
for($p=2;$p < sqrt($n);$p++){
if(@$A[$p] != 0){
$j = $p * $p;
while($j <= $n){
@$A[$j] = 0;
$j = $j + $p;
print $j,"\t";
}
}
}
Comment