Lucian_Adrian

#45 VerifPrim

Oct 26th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n,prim=1;
  6.  
  7. cin >> n;
  8.  
  9.  
  10. if(n<2)
  11. prim = 0;
  12.  
  13. if(n % 2 == 0 && n > 2)
  14. prim = 0;
  15.  
  16. for(int i = 3; i * i <= n; i = i + 2)
  17. if(n % i == 0)
  18. prim = 0;
  19.  
  20.  
  21. cout << (prim ? "DA" : "NU") << endl;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment