+ 2
Program to calculate prime numbers
2 Answers
+ 1
This code would help you to identify if a number is prime. To calculate a set of prime number use a loop (for..) and print only the values returned true by isPrime().
bool isPrime(int x) {
if (x<=0) return false; // i don't test those values
if (x<2) return true; // 1 and 2 are primes!
for (int i=2;i<x;i++) {
if (x%i==0) return false;
}
return true;
}
Please take a look to my code:
https://code.sololearn.com/c8gjJwr0o455/?ref=app
0
do by yourself...for(i=2;i<10;I++)
if(number%i==0)
count++;