Advertisement
Tariqul_Islam

Resursive prime

Jun 26th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2. int prime(int x, int y, int count)
  3. {
  4.     if(y<=x)
  5.     {
  6.        if(x%y==0)
  7.        {
  8.            count++;
  9.        }
  10.        y++;
  11.        return prime(x,y,count);
  12.     }
  13.     return count;
  14. }
  15. int main()
  16. {
  17.     int n,res;
  18.     scanf("%d",&n);
  19.     res=prime(n,1,0);
  20.     if(res<=2)
  21.     {
  22.         printf("Prime");
  23.     }
  24.     else
  25.     {
  26.         printf("Not Prime");
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement