prime number is only divisible by 1 and itself, we can easily write prime number program in c++, just check number is not divisible by any other numbers except 1 and number itself.
A prime number is a whole number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23 2 is the only even Prime number. Prime number program in C++. Every prime number can represented in form of 6n+1 or 6n-1, where n is natural number. 2, 3 are only two consecutive natural numbers which are prime too.
Super logic.............
ReplyDeletePrime number program in C++
ReplyDeleteprime number is only divisible by 1 and itself,
we can easily write prime number program in c++, just check number is not divisible by any other numbers except 1 and number itself.
can you write the program with using only while loop?
ReplyDeleteYou mean avoid the usage of do-while ??
DeleteA prime number is a whole number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23
ReplyDelete2 is the only even Prime number. Prime number program in C++. Every prime number can represented in form of 6n+1 or 6n-1, where n is natural number. 2, 3 are only two consecutive natural numbers which are prime too.