#8472: c 逾時 = = 我不知道該說什麼了.......


l13013312333 (Wood Ghost)


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
 int num, i, j;
 
 while(scanf("%d", &num) != EOF){
  if (num >= 2 && num <= 2147483647){
   j = 1;
   for (i = 2;i <= sqrt(num) -1; i++){
     if (num % i == 0) {
     j = 0;
     break;
     }
   }
   if (j == 0)   printf("非質數\n");
   else   printf("質數\n");
  }
 }
 return 0;
}

#8473: Re:c 逾時 = = 我不知道該說什麼了.......


l13013312333 (Wood Ghost)


請問有更簡略的方法嗎?