Skip to content

Instantly share code, notes, and snippets.

@mikestratton
Last active August 29, 2015 14:20
Show Gist options
  • Save mikestratton/966781d59b4609d37107 to your computer and use it in GitHub Desktop.
Save mikestratton/966781d59b4609d37107 to your computer and use it in GitHub Desktop.
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