You are on page 1of 3

c  c


„ „


• 

 

 
p

p
To print the prime series.

 
a.p àtart

2.p Enter the limit as n.

3.p Run a loop from i = 2 to n.

4.p Run an inner loop from j=2 to i.

4.a.End the loop if i%j==0.

5.p End the inner loop if j is greater than i.

6.p Print the value of i if i is equal to j.

7.p End the outer loop if i is greater than n.

8.p àtop

p
p
p
p
p
p
c  c

„ „

p
p
p

 p
p
print"Enter the limit: ";
$n=<stdin>;
print "The prime series is as printed below\n";
for($i=2; $i<=$n; $i++)
{
for($j=2; $j<=$i; $j++)
{
last if($i%$j==0);
}
if($i==$j)
{
print"$i\n";
}
}

p
p
p
p
p
p
p
p
p
p
p
p
p
p
p
c  c 
„ „

p
p
p
 p
p
Enter the limit: 50
The prime series is as printed below
2
3
5
7
aa
a3
a7
a
23
2
3a
37
4a
43
47p
p
p
p
p
p
p
p
p
p
p
p
p
p
p
 p
p
Thus the PERL program to print the prime series was successfully executed and its output
was verified.

You might also like