Advertisement
CatalinCosmin

cod personal

Dec 16th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int vPrim(int n)
  6. {
  7.     if(n==2 || n==5 || n==3) return 1;
  8.     if(n%2==0||n%5==0||n%3==0) return 0;
  9.     if(n>5)
  10.     {
  11.         if((n-1)%6==0)
  12.         {
  13.             if(int(sqrt(n))!=sqrt(n)) return 1;
  14.         }
  15.         else if((n+1)%6==0)
  16.             if(int(sqrt(n))!=sqrt(n)) return 1;
  17.     }
  18.     return 0;
  19. }
  20.  
  21. int main()
  22. {
  23.     int n;
  24.     cin >> n;
  25.     if(vPrim(n))
  26.         cout << "DA";
  27.     else cout << "NU";
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement