2024-01-12 13:37:52 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-01-18 12:00:34 +01:00
|
|
|
max_prime(250);
|