[Solved] C++ : using prime number and not a prime number


Just define a Boolean variable and set its value to ‘true’. You only need to run a loop “n/2 times” as the maximum divisor is half of the actual number. So, if the input number is divisible by any value between ‘2-n/2’, set the value of Boolean variable false. In the end, print the result on the basis of Boolean variable value.
Have a look at this link!

https://www.programiz.com/cpp-programming/examples/prime-number

3

solved C++ : using prime number and not a prime number