Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool czy_pierwsza(int n)
- {
- if (n<2) return false;
- for(int i=2;i<=sqrt(n);i++)
- if(n%i==0)
- return false; //gdy znajdziemy dzielnik, to dana liczba nie jest pierwsza
- return true;
- }
- int main()
- {
- int test,n;
- cin>>test;
- for(int i=0; i<test; i++)
- {
- cin>>n;
- if(czy_pierwsza(n))
- {
- cout<<"TAK"<<endl;
- }
- else cout<<"NIE"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement