Programs of Loops
Find prime numbers and traverse arrays in a circular manner.
We'll cover the following...
Store the first n prime numbers in the array
The following program stores the first n prime numbers to an array. The value of n is chosen by the user, and any number can be used. Here’s how to solve this problem:
- Start with an empty array of
nelements. - Store as the first prime number at the index.
- Keep checking every following integer by dividing it by every prime value in the array.
- Check
Ask