#include #include using namespace std; int nbPrem(int res, int table[]){ cout << "ici"; int i,pn,c,k; for(i=2;i<=res;i++){ table[i]=i; } pn=table[2]; c=1; k=2; cout << "ici"; int lim=pow(res,0.5); while(pn<=lim){ while(table[k]==-1){ k++; } pn=table[k]; for(i=pn+1;i<=res;i++){ if(table[i]%pn==0){ table[i]=-1; }else{ c++; } } } return(c); } int main(){ int n,i,k,c; cout << "Jusqu'à combien voulez-vous rechercher des nombres premiers ? : "; cin >> n; int table[n]; c=nbPrem(n, table); int nbp[c]; k=2; for(i=0;i<=c;i++){ while(table[k]==-1){ k++; } nbp[i]=table[k]; } cout << "\nListe des nombres premiers jusqu'à " << n << " : "; for(i=0;i<=c;i++){ cout << nbp[c] << ", "; } }