#6137: 會出錯耶~請幫忙看看~謝謝


skyjerry149 (紅月)


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
   int n,x;
   e: while(cin>>n)
   {
       if(n>=2 && n<=2147483647)
      {
          x=sqrt((double)n);
          if(n==2||n==3||n==5||n==7){cout<<"質數"<<endl; goto e;}
          if(n%2==0||n%3==0||n%5==0||n%7==0) {cout<<"非質數"<<endl; goto e;}
          for(int i=2;i<=x;i+=2)
          {
              if(n%i==0) {cout<<"非質數"<<endl; goto e;}
              else {cout<<"質數"<<endl; goto e;}
           }
        }
    }
}