Showing posts with label Combination. Show all posts
Showing posts with label Combination. Show all posts

Find all combination which follow Pythagorean theorem for given Hypotenuse Length


package javaFixer;

/**
 * Program #5 Program To find all combination of sides which follow Pythagorean
 * Theorem for given Hypotenuse length
 * 
 * @author JavaFixer
 *
 */
public class Pythagorean {

 public static void main(String[] args) {
  int n = 100; // Length of Hypotenuse

  for (int i = 0; i < n; i++) {
   for (int j = i; j < n; j++) {
    if ((i * i) + (j * j) == (n * n)) {
     System.out.println(i + "-" + j + "-" + n);
    }
   }
  }
 }
}


28-96-100
60-80-100