# project-euler/136/euler-135.pl

-Given the positive integers, x, y, and z, are consecutive terms of an

-arithmetic progression, the least value of the positive integer, n, for which

-the equation, x2 − y2 − z2 = n, has exactly two solutions is n = 27:

-342 − 272 − 202 = 122 − 92 − 62 = 27

-It turns out that n = 1155 is the least value which has exactly ten solutions.

-How many values of n less than one million have exactly ten distinct solutions?

-(z+2d)^2 - (z+d)^2 - z^2 = z^2+4dz+4d^2 - z^2 - 2dz - d^2 - z^2 =

--z^2 + 2dz +3d^2 = (-z + 3d)(z + d)

-my $solution_counts_vec = '';

- print "Z = $z ; Ten Counts = $ten_counts\n" if ($z % 10_000 == 0);

- my $n = (3*$d-$z)*($z+$d);

- my $c = vec($solution_counts_vec, $n, 4);

- # Make sure it doesn't overflow.

- vec($solution_counts_vec, $n, 4) = $c;

-print "Ten counts = $ten_counts\n";

# project-euler/136/euler-136.pl

+The positive integers, x, y, and z, are consecutive terms of an arithmetic

+progression. Given that n is a positive integer, the equation, x2 − y2 − z2 =

+n, has exactly one solution when n = 20:

+In fact there are twenty-five values of n below one hundred for which the

+equation has a unique solution.

+How many values of n less than fifty million have exactly one solution?

+(z+2d)^2 - (z+d)^2 - z^2 = z^2+4dz+4d^2 - z^2 - 2dz - d^2 - z^2 =

+-z^2 + 2dz +3d^2 = (-z + 3d)(z + d)

+my $solution_counts_vec = '';

+foreach my $z (1 .. ($LIMIT-1))

+ print "Z = $z ; Ten Counts = $ten_counts\n"; # if ($z % 10_000 == 0);

+ my $n = (3*$d-$z)*($z+$d);

+ my $c = vec($solution_counts_vec, $n, 2);

+ # Make sure it doesn't overflow.

+ vec($solution_counts_vec, $n, 2) = $c;

+print "Ten counts = $ten_counts\n";