Last active
August 29, 2015 14:20
-
-
Save mikestratton/966781d59b4609d37107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; // initialize scanner | |
// Pythagorean Theorem a^2 + b^2 = c^2 | |
public class PythagoreanTriple | |
{ | |
public static void main( String[] args ) | |
{ | |
for ( int a = 1; a <= 500; a++ ) | |
{ | |
for ( int b = 1; b <= 500; b++ ) | |
{ | |
for ( int c = 1; c <= 500; c++ ) | |
{ | |
if( (a * a) + (b * b) == (c * c) ) | |
{ | |
System.out.printf( “%d, %d, %d”, a, b, c ); | |
System.out.println(); | |
} // end if | |
} // end 3rd loop inside of 2nd loop | |
} // end 2nd loop inside of first loop | |
} // end first loop | |
} // end method main | |
} // end class PythagoreanTriple |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment