Horje
recursion c prime number Code Example
recursion c prime number
    #include<stdio.h>

int isPrime(int,int);

int main(){

    int num,prime;

    printf("Enter a positive number: ");
    scanf("%d",&num);

    prime = isPrime(num,num/2);

   if(prime==1)
        printf("%d is a prime number",num);
   else
      printf("%d is not a prime number",num);

   return 0;
}

int isPrime(int num,int i){

    if(i==1){
        return 1;
    }else{
       if(num%i==0)
         return 0;
       else
         isPrime(num,i-1);
    }
}




C

Related
printf in c Code Example printf in c Code Example
round function in C Code Example round function in C Code Example
rounding decimal number in C Code Example rounding decimal number in C Code Example
how to reverse a string in c Code Example how to reverse a string in c Code Example
How to make a printf in c Code Example How to make a printf in c Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10