Question 6

Print First N Prime numbers

N – range of prime numbers to be printed

Algorithm:

#1 Get the input range

#2 Initialize the number with ‘2’(since prime number starts with 2)

#3 Loop within the input range

#4 Check whether the number is prime

#5 If not prime break the loop

#6 Else it is a prime add it to the output

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s