By DePaul Dimadis
Choose your prefered Language: greek_flag uk_flag

Some prime numbers, lets say Pn, are called good primes if they satisfy the following condition:

  • Pn ^ 2> Pn-1 * Pn + 1

Some numbers like these are: 5, 11, 17, 29, 37, 41, 53, ... (i.e. 5^2 = 25 > 4 * 6 = 24)
Write an algorithm or program in C language that will find and inserts all these prime numbers that are less than 1000 in an one-dimensional array.
At the end you should print out the elements of the array.
(NOTE: The following code section in C language finds if a positive integer k ≥ 2 is a prime number.)
 

i=2; flag=0;
while ((i<=k/2) && (flag==0))
{
if (k%i==0) flag=1;
i++;
}
if (flag==0) printf("number %4d is prime \n",k);