Project Euler – Problem 39

Problem 39: If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.

{20,48,52}, {24,45,51}, {30,40,50}

For which value of p 1000, is the number of solutions maximised?

class runner
{
	public static void main (String[] args) throws java.lang.Exception
	{
		long time = System.currentTimeMillis();
 
		int largest_p = 0, largest_counter = 0;
		
		//3+4+5 = 12
		for(int p=12; p<1000; p++){
			int counter = 0;
			
			for(int a=3;a


Note: Brute Force... better way is to generate the triples. [2sec]