fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool isPrime(int n){
  4. if(n==1)
  5. return false;
  6. if(n==2)
  7. return true;
  8. for(int i=2;i<=sqrt(n);i++){
  9. if(n%i!=0)
  10. continue;
  11. else
  12. return false;
  13. }
  14. return true;
  15. }
  16. int main() {
  17. // your code goes here
  18. int num=0;int t=0;
  19. cin>>t;
  20. while(t-->0){
  21. cin>>num;
  22. if(isPrime(num)){
  23. cout<<num<<" "<<"prime"<<endl;
  24. }
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 4420KB
stdin
4
11
31
71
26
stdout
11 prime
31 prime
71 prime