Pythagoras' Other Leg Pythagoras had his leg blown up in the war. It had to be amputated, and though he nearly died, he pulled through and made a full recovery. Now, after a year of walking with crutches, he gets the privilege of getting a prosthetic leg! Thing is, though, there are several that fit, but which ones?

The Task

Given a positive integer as input that is the length of one leg of a Pythagorean triple, output all possibilities for the other leg. For example, the smallest Pythagorean triple is (3,4,5), which forms a triangle with two legs of length 3 and 4, and a hypotenuse of length 5.

Examples

Leg:5
12

Leg:28
21
45
96
195

Leg:101
5100

Leg:1001
168
468
660
2880
3432
4080
5460
6468
10200
38532
45540
71568
501000


The Rules


Input will be a single positive integer n.
Output may be in any order, with any delimiter, in any base (though this base must be consistent), and with optional opening and closing braces, and optional trailing whitespace. That is, 1 2 3, [1,2,3], and 1,11,111 all fit this output specification.
You may assume that n will never be larger than one fourth of the fourth root of your language's limit (without using libraries). In practice, you may assume the input will be less than either this or 10,000, whichever is less.


Pythagoras is waiting on you, so better write your code quick and short!
Jelly, 8 bytes

²R²+²Æ²O


This answer is non-competing, since it uses features that have been implemented after the challenge was posted. Try it online!

This approach does not use floating point math, so it will give the correct answer as long as the intervening lists can fit into memory.

Idea

If (a, b, c) is a Pythagorean triple, there are strictly positive integers k, m, n such that the set equality {a, b} = {km2 - kn2, 2kmn} holds.

In particular, this means that a &lt; b2 and b &lt; a2, so for input a we can simply check if a2 + b2 is a perfect square for each b in {1, &hellip; a2}.

Code

            Input: x

²           Compute x².
 R          Get get range 1 ... x².
  ²         Square each integer in that range.
   +²       Add x² to each resulting square.
     Æ²     Check if the resulting sums are perfect squares.
       O    Get all indices of ones.