-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid0046.c
More file actions
43 lines (33 loc) · 728 Bytes
/
id0046.c
File metadata and controls
43 lines (33 loc) · 728 Bytes
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
40
41
42
43
// Licensed under the MIT License.
// Goldbach's Other Conjecture
#include "../lib/euler.h"
#include "../lib/primality_test.h"
static bool math_is_goldbach_other_conjecture(long n)
{
long m;
for (long i = 0; (m = 2 * i * i) < n; i++)
{
if (miller_rabin_primality_test(n - m) == PRIMALITY_PRIME)
{
return true;
}
}
return false;
}
int main(void)
{
clock_t start = clock();
long n;
for (n = 9; ; n += 2)
{
if (miller_rabin_primality_test(n) == PRIMALITY_PRIME)
{
continue;
}
if (!math_is_goldbach_other_conjecture(n))
{
break;
}
}
return euler_submit(46, n, start);
}