用C语言中的conio.h实现求给定正整数n以内的素数之积(n<28)
时间: 2023-12-22 08:04:10 浏览: 83
```c
#include <stdio.h>
#include <conio.h>
int is_prime(int n);
int main() {
int n, i, product = 1;
printf("Enter a positive integer n (n<28): ");
scanf("%d", &n);
for (i = 2; i <= n; i++) {
if (is_prime(i)) {
product *= i;
}
}
printf("The product of prime numbers less than or equal to %d is %d", n, product);
getch();
return 0;
}
int is_prime(int n) {
int i;
for (i = 2; i <= n / 2; i++) {
if (n % i == 0) {
return 0;
}
}
return 1;
}
```
阅读全文