-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid0004.c
More file actions
47 lines (37 loc) · 735 Bytes
/
id0004.c
File metadata and controls
47 lines (37 loc) · 735 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
44
45
46
47
// Licensed under the MIT License.
// Largest Palindrome Product
#include "../lib/euler.h"
int main(void)
{
long max = 0;
clock_t start = clock();
for (int a = 999; a >= 100; a--)
{
int b;
int db;
if (a % 11 == 0)
{
b = 999;
db = -1;
}
else
{
b = 990;
db = -11;
}
while (b >= a)
{
long product = a * b;
if (product <= max)
{
break;
}
if (math_is_palindrome(product))
{
max = product;
}
b += db;
}
}
return euler_submit(4, max, start);
}