C Programming Code Examples C > Mathematics Code Examples Prime Number Program In C Programming language Prime Number Program In C Programming language Any whole number which is greater than 1 and has only two factors that is 1 and the number itself, is called a prime number. Other than these two number it has no positive divisor. #include <stdio.h> int main() { int loop, number; int prime = 1; number = 21; for(loop = 2; loop < number; loop++) { if((number % loop) == 0) { prime = 0; } } if (prime == 1) printf("%d is prime number.", number); else printf("%d is not a prime number.", number); return 0; } procedure prime_number : number FOR loop = 2 to number - 1 check if number is divisible by loop IF divisible RETURN "NOT PRIME" END IF END FOR RETURN "PRIME" end procedure