+ 1
Print primes numbers
Write a function to compute and print all the prime numbers up to the number user wish to see.....
2 Antworten
0
In C++ :
void printPrimes(int num)
{
int i, j;
for(i = 2; i <= num; i++)
{
for(j = 2; j <= i/2; j++)
{
if(i % j == 0){break;}
if(j >= i/2){cout<<i<<endl;}
}
}
}
But please, don't name your question like you did. Give them name of your actual problem - such as [ASSIGNMENT] Print primes.
+ 6
you should do by yourself. there're many codes and tutorials for prime numbers here. https://www.sololearn.com/learn/969/?ref=app