making a program to find all the prime numbers up to a certain number.
I've tried changing the for loops and the if statement.
#include <iostream>
using namespace std;
int main(){
double x;
double y = 0;
cout << "Enter an input range: ";
cin >> x;
for (int i;i<=x;){
for(int p;p<=i-1;i++){
if(i%p==0;){
break;
} else{
y+=1;
cout << i << " #" << y << endl;
}
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire