fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5. int main()
  6. {
  7. int t ;
  8. scanf("%d",&t);
  9. for(int cs = 1; cs<=t ; cs++)
  10. {
  11. int n,prime = 1;
  12. scanf("%d",&n);
  13.  
  14. if(n==1 || n%2 == 0)
  15. {
  16. printf("Not Prime\n");
  17. continue;
  18. }
  19. else if(n==2 || n == 3)
  20. {
  21. printf("Prime\n");
  22. continue;
  23. }
  24. else
  25. {
  26. for(int i = 5 ; i<=sqrt(n) ; i+=2 )
  27. {
  28. if(n%i == 0)
  29. {
  30. printf("Not Prime\n");
  31. prime = 0;
  32. continue;
  33. }
  34. }
  35. }
  36. if(prime)
  37. printf("Prime\n");
  38. }
  39.  
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 4496KB
stdin
5
3
7
67
69
1001
stdout
Prime
Prime
Prime
Prime
Not Prime
Not Prime
Not Prime