import java.util.*; // Test whether three numbers a, b, c entered by the user // form a pythagorean triple, that is a^2 + b^2 == c^2 class PythGenerate { public static void main(String[] args) { int n, a, b, c; Scanner in = new Scanner(System.in); // Get n from the user System.out.print("Enter n: "); n = in.nextInt(); for(int i = 1; i <= n; i++) { for(int j = i; j <= n; j++) { double k = Math.sqrt(i*i + j*j); if(k - (int)k == 0) System.out.println(i + "," + j + "," + (int)k); } } } }