blob: 4ad1c3b079ebc341d5e60ab42ba4079a7d527175 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <stdio.h>
#include <math.h>
char prime(unsigned long long m)
{
unsigned long i;
for (i = 3; i <= sqrt(m); i += 2)
if (m % i == 0)
return 0;
return 1;
}
int main()
{
unsigned long long n, i;
scanf("%lld", &n);
if (n == 1) {
puts("2");
return 0;
}
i = (n % 2) ? n : n - 1;
while (i <= 18446744073709551615ULL) {
i += 2;
if (!prime(i))
continue;
printf("%lld\n", i);
return 0;
}
}
|