Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool ProstBroj(int n)
- {
- if (n==1) return false;
- if (n==2) return true;
- int sqn=sqrt(n);
- for (int i=3;i<=sqn;i=i+2)
- if (n%i==0) return false;
- return true;
- }
- int main()
- {
- int n;
- cin>>n;
- if (ProstBroj(n)) cout<<"Uneseni broj je prost"<<endl;
- else cout<<"Uneseni broj nije prost"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement