intmain() { int num; scanf("%d", &num); int i = 0; for (i = 2; i <= num-1; i++) { if (num % i == 0) { break; } } if (i == num) { printf("%d is a prime number.", num); } else { printf("%d is not a prime number.", num); }
intmain() { int num = 0; scanf("%d", &num); int isPrime = 1; int i = 0; if (num <= 1) { isPrime = 0; } else { for (i = 2; i <= num-1; i++) { if (num % i == 0) { isPrime = 0; break; } } }
if (isPrime) { printf("%d is a prime number.", num); } else { printf("%d is not a prime number.", num);
intmain() { int num = 0; int i = 0; scanf("%d", &num);
for (i = 2; i <= num / 2; i++) { if (num % i == 0) { break; } } if (i == num / 2 + 1) { printf("%d is a prime number", num); } else { printf("%d is not a prime nuber.", num); }
intmain() { int i = 0; int num = 0; scanf("%d", &num); int limit = sqrt(num); for (i = 2; i <= limit; i++) { if (num % i == 0) { break; } } if (i > limit) { printf("%d is a prime number", num); } else { printf("%d is not a prime number", num); }
intmain() { int num = 0, i = 0; for (num = 2; num < 100; num++) { for (i = 2; i <= (int)sqrt(num); i++) { if (num % i == 0) { break; } } if (i > (int)sqrt(num)) { printf("%d ", num); } }