Recursion c programm if a number is prime
#include <stdio.h>
#include <conio.h>
int isprime(int n, int f)
{
if(n==f)
return 1;
if(n%f==0 || n==1)
return 0;
else
return isprime(n,f+1);
}
int main()
{
int x, f=2;
printf("Enter Number : ");
scanf("%d", &x);
printf("%d", isprime(x, f));
return 0;
}
No comments:
Post a Comment