Advertisement
STANAANDREY

prim rec

Mar 3rd, 2020
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int isPrime(int x, int d)
  5. {
  6.     if (x == 1)
  7.         return 0;
  8.     if (d == 1)
  9.         return 1;
  10.     if (x % d == 0)
  11.         return 0;
  12.     return isPrime(x, d - 1);
  13. }
  14.  
  15. int main()
  16. {
  17.     int x;
  18.     cin >> x;
  19.     cout << isPrime(x, x / 2);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement