-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp023.java
More file actions
34 lines (27 loc) · 819 Bytes
/
p023.java
File metadata and controls
34 lines (27 loc) · 819 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
package level01;
import java.util.List;
import org.junit.Test;
import lib.EulerTest;
public class p023 extends EulerTest {
final int L = 28123;
/**
* Find the sum of all positive integers that cannot be written as the sum of two abundant
* numbers.
*/
@Test
public void test() {
preSumDivisors(L);
List<Integer> abundants = list();
for (int i : range(L))
if (sumProperDivisors(i) > i)
abundants.add(i);
boolean[] sumOfAbundants = new boolean[2 * L];
for (int abundant1 : abundants)
for (int abundant2 : abundants)
sumOfAbundants[abundant1 + abundant2] = true;
for (int i : range(L))
if (!sumOfAbundants[i])
ans += i;
check(4179871);
}
}