Advertisement
rotti321

VerifPrim

Dec 20th, 2021
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main(){
  7. int d,n,prim=1; ///n - numar natural
  8. ///cout<<"n=";
  9. cin>>n;
  10. if(n<=1){
  11. prim=0;
  12. }
  13. for(d=2; d*d<=n; d++){
  14. if(n%d == 0)
  15. {
  16. prim=0;
  17. }
  18. }
  19.  
  20. if(prim==1){
  21. cout<<"prim";
  22. }
  23. else{
  24. cout<<"nu este prim";
  25. }
  26. return 0;
  27. }
Advertisement
RAW Paste Data Copied
Advertisement