橘子味的心
标题:C示例查找Prime编号的程序

C示例查找Prime编号的程序

#include <stdio.h>



int main() {

   int loop, number;

   int prime = 1;



   number = 11;



   for(loop = 2; loop < number; loop++) {

      if((number % loop) == 0) {

         prime = 0;

      }

   }



   if (prime == 1)

      printf("%d is prime number.", number);

   else

      printf("%d is not a prime number.", number);

   return 0;

}

目录

分类