# C Program to check the given number is a prime number or not

**To find a number is a prime number or not, first we need to count the number of factors. **

**The following post has a program to find the factors of a given number. In this, we took a count variable and is initialized to ‘0’. instead of printing the factors, we incremented the count for each factor. for example if the total number of factors is 2, then the given number is a prime number, otherwise, it is not a prime number. **

Click on the following link for a program to print the factors of a given number.

C Program to print the Factors of a given number

Now, the following is the code for checking a number is a prime number or not.

### Output:

Enter any positive integer: 24

24 is not a prime number

——————————–

Process exited after 5.36 seconds with return value 0

Press any key to continue . . .

24 is not a prime number

——————————–

Process exited after 5.36 seconds with return value 0

Press any key to continue . . .