Not tested:
void printPrimes(int n) {
int a = 0, b = 0;
float c = 0.0f;
bool isp = true;
int primes = 0;
while(true) {
a++;
do {
b++;
if(b > 1) {
c = (float)a/(float)b;
if(c = (int)c)
if(b != a) {
isp = false;
break;
}
else
isp=true;
}
} while(b<a);
if(isp) {
primes++;
std::cout << a << endl;
}
if(primes > n)
break;
b = 0;
c = 0;
isp = true;
}
}
void main() {
printPrimes(10);
}
Chat with our AI personalities