Display the First 'n' Prime Numbers
Learn to write pseudocode and draw a flowchart to output the first n prime numbers.
Problem statement
You are required to print the first n prime numbers.
The main steps in problem-solving
Understand the problem
Carefully read the problem and think about the expected output. For instance, if n is 4, the first four prime numbers will be output as 2, 3, 5, and 7.
Come up with a practical solution
One possible solution is to generate numbers starting from 2, check if they are prime, and continue generating them until we have found the first n prime numbers. Since we want to repeatedly generate numbers and check if they are prime or not, we can use a loop.
Note that a prime number is not divisible by any other number except itself and 1. Hence, one possible solution to check if a number num is prime is to ...