Triangular Triples

Run Settings
LanguageJava
Language Version
Run Command
import java.util.ArrayList; class Main { public static void main(String[] args) { System.out.println(triples(25L)); } public static ArrayList triples(long h) { ArrayList<Integer> triples = new ArrayList<Integer>(); int x = 1; long s = h * h; while(x < h) { double temp = s - x * x; //System.out.println("temp=" + temp); double a = Math.sqrt(temp); if (a % 1 == 0) { int y = (int) a; triples.add(x); triples.add(y); } // System.out.println("x=" + x); // System.out.println("a=" + a); x++; } return triples; } }
Editor Settings
Theme
Key bindings
Full width
Lines