22 lines
342 B
C
22 lines
342 B
C
int is_prime(int num) {
|
|
if (num <= 1) return 0;
|
|
for (int i = 2; i * i <= num; i++) {
|
|
if (num % i == 0) return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int max_prime(int limit) {
|
|
int prime = 0;
|
|
|
|
for (int i = 1; i < limit; i++) {
|
|
if (is_prime(i)) {
|
|
prime = i;
|
|
}
|
|
}
|
|
|
|
return prime;
|
|
}
|
|
|
|
max_prime(250);;
|