Anonymous user
Pythagorean quadruples: Difference between revisions
→{{header|Java}}
(→{{header|Ruby}}: added a <lang> xxx </lang> HTML tags, also <pre> and </pre> HTML tags (the old code "swallowed up" Rust's code.) |
|||
Line 757:
=={{header|Java}}==
Replace translation with Java coded implementation.
Compute sequence directly.
static final int MAX = 2200;▼
import java.util.ArrayList;
import java.util.List;
public class PythagoreanQuadruples {
public static void main(String[] args) {
System.out.printf("Values of d < %d where a, b, and c are non-zero and a^2 + b^2 + c^2 = d^2 has no solutions:%n%s%n", d, getPythagoreanQuadruples(d));
// See: https://oeis.org/A094958
for (int a = 1; a <= MAX; a++) {▼
private static List<Long> getPythagoreanQuadruples(long max) {
int a2 = a * a;▼
List<Long> list = new ArrayList<>();
long m = -1;
else {
test = nTest;
}▼
if ( test < max ) {
list.add(test);
}
else {
}
}
return list;
▲ for (int d = 1; d <= MAX; d++) {
▲ }
}
▲}</lang>
}
</lang>
{{out}}
<pre>
Values of d < 2200 where a, b, and c are non-zero and a^2 + b^2 + c^2 = d^2 has no solutions:
[1
</pre>
|