Print primes numbers | Sololearn: Learn to code for FREE!
+ 1

Print primes numbers

Write a function to compute and print all the prime numbers up to the number user wish to see.....

16th Sep 2018, 7:41 PM
Kodees
Kodees - avatar
2 ответов
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.
16th Sep 2018, 7:53 PM
Jan Štěch
Jan Štěch - avatar
+ 6
you should do by yourself. there're many codes and tutorials for prime numbers here. https://www.sololearn.com/learn/969/?ref=app
16th Sep 2018, 7:49 PM
Roneel
Roneel - avatar