+ 1

How to print prime numbers inside C++ As it were 1, 3,5,7,11,13,...... 97 till..

Loop

20th May 2018, 11:40 AM
Mahendra Kumar
Mahendra Kumar - avatar
5 odpowiedzi
+ 4
BTW, '1' is not a prime. https://code.sololearn.com/csfKIN7iPP0R/?ref=app Max : You're free to link a code that gives a more optimum solution to the problem 😃 Thanks for reminding :p https://code.sololearn.com/c3UjQTEiDtZ6/?ref=app
20th May 2018, 12:07 PM
Rahul George
Rahul George - avatar
+ 3
@Rahul George You only need to check up to sqrt(I)
20th May 2018, 1:43 PM
Max
Max - avatar
+ 3
@Rahul George this is as far as i am willing to take it right now https://code.sololearn.com/cm9DhrqT053l/?ref=app
20th May 2018, 6:52 PM
Max
Max - avatar
+ 2
use the modulo operator in a loop.
20th May 2018, 12:04 PM
Idriz Pelaj
+ 1
Just and only prime numbers such as 1,3,5,7,11,13,17,21,23,27,31,33,37,41,.....till..97
20th May 2018, 12:20 PM
Mahendra Kumar
Mahendra Kumar - avatar