Check If A Number Is A Prime Number
Problem:
Write a C++ program which checks if a number is a prime number or not?
A prime number is any natural number greater than 1 with no other positive factors other than 1 and itself.
Let's take 5 as an example:
1 and 5 (the number itself) can evenly divide 5 so they are factors of 5.The program below shows a number is asked and it is evaluated if a prime number or not.
2, 3, 4 are cannot evenly divide 5 so they are not factors of 5.
Therefore, 5 is a Prime Number.