How to use C + + program to judge whether a number is prime or not

How to use C + + program to judge whether a number is prime or not

A prime is a number that has no other factors except one and itself
So just loop to judge whether the number 2 to - 1 is a factor of a number. If you find one, it is not a prime, otherwise it is a prime
A of hypothesis input
for(int i=2;i