Răspuns :
# include <iostream>
using namespace std ;
int main()
{
int n ;
cin >> n ;
int k = 2 ;
while (n)
{
n-- ;
cout << k << ' ' ;
bool flag = true ;
while (flag)
{
flag = false ;
k++ ;
int s = k / 2 ;
for (int j = 2 ; j <= s ; j++)
{
if (k % j == 0)
{
flag = true ;
break ;
}
}
}
}
return 0 ;
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "n= "; cin >> n;
cout << "primele " << n << " numere prime: \n";
if (n==1) cout << 2;
else
{
cout << 2 << " ";
int k=1, num=3, prim;
while (k<n)
{
prim=1;
for (int i=3; i*i<=num; i+=2)
{
if (num%i==0) { prim=0; break; }
}
if (prim==1)
{ cout << num << " "; ++k;}
num=num+2;
}
}
}