C Programming Code Examples C > Recursion Code Examples C Program to Find whether a Number is Prime or Not using Recursion C Program to Find whether a Number is Prime or Not using Recursion The following C program, using recursion, finds whether the entered number is a prime number or not. A prime number is an integer that has no integral factor but itself and 1. #include <stdio.h> int primeno(int, int); int main() { int j, check; printf("Enter a number: "); scanf("%d", &j); check = primeno(j, j / 2); if (check == 1) { printf("%d is a prime number\n", j); } else { printf("%d is not a prime number\n", j); } return 0; } int primeno(int j, int x) { if (x == 1) { return 1; } else { if (j % x == 0) { return 0; } else { return primeno(j, x - 1); } } }