forked from nayuki/Project-Euler-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp069.java
More file actions
32 lines (25 loc) · 729 Bytes
/
p069.java
File metadata and controls
32 lines (25 loc) · 729 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
/*
* Solution to Project Euler problem 69
* Copyright (c) Project Nayuki. All rights reserved.
*
* https://www.nayuki.io/page/project-euler-solutions
* https://github.com/nayuki/Project-Euler-solutions
*/
public final class p069 implements EulerSolution {
public static void main(String[] args) {
System.out.println(new p069().run());
}
private static final int LIMIT = Library.pow(10, 6);
public String run() {
int maxNumer = 0;
int maxDenom = 1;
int[] totients = Library.listTotients(LIMIT);
for (int n = 1; n < totients.length; n++) {
if ((long)n * maxDenom > (long)maxNumer * totients[n]) {
maxNumer = n;
maxDenom = totients[n];
}
}
return Integer.toString(maxNumer);
}
}