+It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples.
+In contrast, some lengths of wire, like 20 cm, cannot be bent to form an integer sided right angle triangle, and other lengths allow more than one solution to be found; for example, using 120 cm it is possible to form exactly three different integer sided right angle triangles.
+120 cm: (30,40,50), (20,48,52), (24,45,51)
+Given that L is the length of the wire, for how many values of L ≤ 1,500,000 can exactly one integer sided right angle triangle be formed?
+Note: This problem has been changed recently, please check that you are using the right parameters.
+ return gcd($m,$n % $m);
+my $half_limit = ($limit >> 1);
+my $hypotenuse_lim = int($limit/2);
+my $major_side_limit = int($limit/2);
+my $m_limit = int(sqrt($hypotenuse_lim));
+for my $m (2 .. $m_limit)
+ my $n = ((($m & 0x1) == 0) ? 1 : 2);
+ if (gcd( $m, $n ) == 1)
+ my $half_sum = $m * ($m + $n);
+ if ($half_sum > $half_limit)
+ if (vec($verdicts, $half_sum, 2) != 2)
+ while (($sum_product += $half_sum) < $half_limit)
+ if (vec($verdicts, $sum_product, 2) != 2)
+ vec($verdicts, $sum_product, 2)++;
+foreach my $sum_idx ((12>>1) .. ($limit>>1))
+ if (vec($verdicts, $sum_idx, 2) == 1)
+print "Count = $count\n";