Lucian_Adrian

#14 Primalitate

Feb 12th, 2022
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.20 KB | None | 0 0
  1. int prim(int x){
  2. if (x<2)
  3. return 0;
  4. if(x==2)
  5. return 1;
  6. if(x%2==0)
  7. return 0;
  8. for(int n=3;n*n<=x;++n)
  9. if(x%n==0)
  10. return 0;
  11. return 1;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment