Question:

Check for Prime using recursion

by Guest554  |  earlier

0 LIKES UnLike

 Tags:

   Report

1 ANSWERS


  1. void prime (int a)
    {
      static int i=1,cnt=0;
      if(i<=a)
       {
         if(a%i==0)
          cnt++;
          i++;
          prime(a);
        }
       if(cnt==2)
       printf(" this is a prime number");
      else
       printf("This is not a prime number");
    }

    void main()
    {
      int n;
      clrscr();
      printf("Enter the value of n \");
      scanf("%d",&n);
      
       prime(n);
       getch();
    }

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions