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