-
Notifications
You must be signed in to change notification settings - Fork 0
/
id0047.c
48 lines (37 loc) · 782 Bytes
/
id0047.c
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
44
45
46
47
48
// Licensed under the MIT License.
// Distinct Primes Factors
#include "../lib/euler.h"
#define MAX_SEARCH 1000000l
int main(void)
{
clock_t start = clock();
int* divisors = calloc(MAX_SEARCH, sizeof * divisors);
euler_assert(divisors);
long n;
int length = 0;
for (n = 2; n < MAX_SEARCH; n++)
{
if (divisors[n] == 4)
{
length++;
if (length == 4)
{
break;
}
}
else
{
length = 0;
}
if (divisors[n])
{
continue;
}
for (long j = n + n; j < MAX_SEARCH; j += n)
{
divisors[j]++;
}
}
free(divisors);
return euler_submit(47, n - 3, start);
}