fork download
  1. // Online C++ compiler to run C++ program online
  2. #include <iostream>
  3. #include<math.h>
  4. using namespace std;
  5. int main() {
  6. int n,f=1;
  7. cin>>n;
  8.  
  9. for(int i=2;i<sqrt(n);i++){
  10. if(n%i==0)
  11. f=0;
  12. break;
  13. }
  14. if(f==1){
  15. cout<<"n is prime"<<endl;
  16. cout<<sqrt(n);
  17. }
  18. else {
  19. cout<<"not Prime ";
  20. }
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5316KB
stdin
45
stdout
n is prime
6.7082