📜  质数检查程序 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:44.100000             🧑  作者: Mango

代码示例1
#include  

main() {
  int n, i, c = 0;
  printf("Enter any number n:");
  scanf("%d", &n);

  //logic
  for (i = 1; i <= n; i++) {
      if (n % i == 0) {
         c++;
      }
  }

  if (c == 2) {
  printf("n is a Prime number");
  }
  else {
  printf("n is not a Prime number");
  }
  return 0;    
}
Program Output: