#include<iostream>
#include<iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setw;
int main()
{
long* pprime = 0; //initialize long point;
long max = 4; // number of primes required;
long count = 3; // number of primes found;
long found = 0; // indicates when a prime found;
long trial = 5;// candidate the prime
pprime = new long[max];
cout << "please enter the number of primes you would like (at least 4):"<<endl;
cin >> max;
if (max<=4)
max = 4;
*pprime = 2;
*(pprime+1) = 3;
*(pprime+2) = 5;
do
{
trial+=2;
found =0;
for(int i=0;i<count;i++)
{
found = trial%*(pprime+i)==0;
if (found)
break;
}
if (found == 0)
*(pprime+count++) = trial;
}while(count<max);
for(int i=0;i<max;i++)
{
if(i%5 == 0)
cout<<endl;
cout<<setw(5)<<*(pprime+i);
}
delete [] pprime;
pprime = 0;
cout<<endl;
return 0;
}