# C Program to Check given number is prime number or not using Recursion

## C Program to Check given number is prime number or not using Recursion

This page has C Program to Check given number is prime number or not using Recursion. Prime numbercan be checked by using recursion. The recursion is a process which call the function itself. A few Prime number examples: 5,  11, 17, 23, 19, 29, 3, 37, 43, 7, 53. The below given C program to Check given number is prime number or not using Recursion. In this page, I have used a recursion technique to check a number whether it belongs prime or not. Kindly check out the programs to Check a given number is prime number or not using Recursion.

### Program to Check given number is prime number or not using Recursion

#include<stdio.h>
int prime(int, int);
int main(){
int np,remcheck=1;
clrscr();
printf("Give a Positive whole number : \n");
scanf("%d", &np);
remcheck = prime(np, np/2);
if(remcheck==1)
printf("The Entered Number %d is Prime",np);
else
printf("The Entered Number %d is not Prime",np);
getch();
return(0);
}

int prime(int npf, int maxfind){
if(maxfind == 1)
return(1);
else
{
if(npf % maxfind == 0)
return(0);
prime(npf, maxfind-1);
}
}

Sample output:

Give a Positive whole number :  53

The Entered Number 53 is Prime

Give a Positive whole number :  26

The Entered Number 26 is not Prime

Related Popular Posts: