[Question]
  [
## Definition (from Wikipedia)
**A Pythagorean triple consists of three positive integers a, b, and c, such that a² + b² = c².**
The typical example of a Pythagorean triple is (3,4,5): 3² + 4² = 9 + 16 = 25 which is 5²
## Task:
Given an integer number `c`, write a program or function that returns the list of pythagorean triples where `c` is the hypotenuse.
The triples do not need to be primitive.
For example: if c=10, the answer will be `[[6,8,10]]`
## Input:
An integer number, the hypotenuse of the possible triples
## Output:
A list of triples, eventually empty. Order is not important, but the list must be duplicate-free ([3,4,5] and [4,3,5] are the same triple, only one must be listed)
Test cases:
```
5    -> [[3,4,5]]
7    -> []          # Empty
13   -> [[5,12,13]]
25   -> [[7,24,25],[15,20,25]]
65   -> [[16,63,65],[25,60,65],[33,56,65],[39,52,65]]
1105 -> [[47,1104,1105],[105,1100,1105],[169,1092,1105],[264,1073,1105],[272,1071,1105],[425,1020,1105],[468,1001,1105],[520,975,1105],[561,952,1105],[576,943,1105],[663,884,1105],[700,855,1105],[744,817,1105]]
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest entry for each language wins.
  
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), ~~11~~ 10 bytes
```
ɾ2ḋvp'²ḣ∑=
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C9%BE2%E1%B8%8Bvp%27%C2%B2%E1%B8%A3%E2%88%91%3D&inputs=25&header=&footer=)
*-1 byte thanks to @lyxal*
Thanks for the offer @lyxal, but nah, I don't need flags.
```
ɾ2ḋvp'²ḣ∑=    Full program, input: n, the hypotenuse
ɾ             1..n
 2ḋ           All pairs (2-combinations) without replacement
   vp         Prepend n to each pair
     '        Filter those which satisfy...
      ²         Square each number
       ḣ∑=      Does the sum of last two equal the first?
```
---
# [Vyxal](https://github.com/Vyxal/Vyxal), 15 bytes
```
ɾ:Ẋ's=*²∑⁰²=;vJ
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C9%BE%3A%E1%BA%8A%27s%3D*%C2%B2%E2%88%91%E2%81%B0%C2%B2%3D%3BvJ&inputs=25&header=&footer=)
Kinda port of my own [Jelly answer](https://codegolf.stackexchange.com/a/236382/78410), using filter instead of "truthy n-D indices".
```
ɾ:Ẋ's=*²∑⁰²=;vJ   Full program, input: n, the hypotenuse
ɾ:Ẋ               All pairs between 1..n and 1..n
   '        ;     Filter the pairs where...
    s=*             it is sorted and
       ²∑⁰²=        the sum of square is equal to n squared
             vJ   Append n to each pair
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/mathematica/), ~~41~~ ~~40~~ 39 bytes
```
Solve[a^2+b^2==c#>c==#>b>a>0,Integers]&
```
-1 byte from ovs
-1 byte from att
`Integers` restricts it to integers; `>0` restricts it to positive integers; and `b>a` removes the duplicates. `c#` is c^2; `c==#` adds the input to each solution set (as required by the OP).
Alternately (also 39 bytes):
```
Solve[Norm@{a,b}==c==#>b>a>0,Integers]&
```
Here's a more verbose version that's similar to the first approach:
```
Solve[{a^2+b^2==#^2,c==#,b>a>0},Integers]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n277Pzg/pyw1OjHOSDspzsjWNlnZLtnWVtkuyS7RzkDHM68kNT21qDhW7X9AUWZeiUN6tGksF4xpjmAaGiPYRkhKzJDYhoYGprH/AQ)
[Answer]
# Excel, ~~100~~ ~~93~~ 90 bytes
```
=LET(a,SEQUENCE(A1),b,TRANSPOSE(a),CONCAT(IF((a<b)*(a^2+b^2)-A1^2,"",a&","&b&","&A1&"
")))
```
Input is in A1. Triples are delimited by a comma and each triple is separated by a new line with a trailing new line. The `LET()` and `SEQUENCE()` functions are only available in certain versions of Excel.
[![Screenshot1](https://i.stack.imgur.com/NTCze.png)](https://i.stack.imgur.com/NTCze.png) [![Screenshot2](https://i.stack.imgur.com/LOxaz.png)](https://i.stack.imgur.com/LOxaz.png)
`LET()` allows us to define variables and reference them later. This goes a long way towards saving bytes. The final parameter doesn't define a variable and instead is the output result.
`a,SEQUENCE(c)` creates a 1D array of numbers from 1 to the input.
`b,TRANSPOSE(a)` creates the same array as `a` except transposed. This lets us work with a matrix of `a`x`b` so we can evaluate all possible combinations of integers less than or equal to the input.
```
CONCAT(IF((a>b)*(a^2+b^2)-A1^2,"",a&","&b&","&A1&"
"))
```
This is where all the calculation and concatenation happens so I'll break it into pieces.  
`(a>b)*(a^2+b^2)-A1^2` does the math bit to check if it's a triple and, thanks to `(a>b)`, ignores half the results so we don't have duplicates. You cannot have a Pythagorean triple where `a=b` so this is an OK filter. We can use `(~)-A1^2` instead of `(~)<>A1^2` since Excel will interpret 0 as False and any non-zero number as True.  
`a&","&b&","&A1&"\n"` (where `\n` is a literal line break in the original formula) creates a text string in the format `a,b,A1` with a trailing new line. These are the results that show up at the end.  
`CONCAT(IF(~,"",~))` combines all the results into one big string. Those results are either triples with a trailing new line or blank text. This is what creates the final output.
[Answer]
# [Haskell](https://www.haskell.org/), 46 bytes
```
f c=[[a,b,c]|a<-[1..c],b<-[a..c],a*a+b*b==c*c]
```
[Try it online!](https://tio.run/##PY/NboMwEITveYoV6gHCNvK/oSpv0J56dKzKUFCqJjRqUjWR8u7UxsEc0Dc7M8uyc6evfr@fpgG6xhiHLXb25p4fDd1sOoutJzeTW7uyXbdN0607Ox3c5wgNHNzx9R2Ov@e388/LCCYbcsjKMj/tvv/gUkBZQgYFPG3HLPA8fxgWZzv2l2PfnfuPJTD3rnczg1t@wWvhT1hBLgHBGI4CpbUF@okOEwvhKRDATyifQxIpQ8rvMRabGplAJi0aKpGRgNFX0acKFUcVAkyiIhE5R6nuWKNkAWONUhKLQqNnEV7zdiIDkqRVjZTUbNFM@SjRPGnNgqaLFv7rlLDUF6rymiRfeqvWMklFsZZpu9QKa5GWK/9LVZVu0/6sSqauFgIrqqO0hbWr6R8 "Haskell – Try It Online")
* List comprehension made of all combinations *a<-[1..c],b<-[a..c]* with our Pythagorean condition as guard.  
We add `c` to the pair yelded.
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~67 65~~  53 bytes
```
->c{c.times{|a|a.times{|b|p [b,a,c]if a*a+b*b==c*c}}}
```
[Try it online!](https://tio.run/##ZY/BbsMgEETv/goU39xtxAIL5uDe@hWIA0aNFCmRrMQ5RLG/3YU65uByQPM0s8Nye/TP5dQtn1/xFY/j@fpzf01hCpvsp4G5HgJEfz6x0ISPvum7LjZxnuelOh1juFwYMcZq5pwEBeR9NTzG@@GwuWZ1PSunZt/XYXzucijXFgIUgPJfj6DVNyAUCPLgkEDwLPdR/Y6iBi1B56wg0HyVUgLpt7RAIst9AyInVjunDCSp8vX3IqcseWFtAbkVGwudotzIwkZkxo1VWgO5KPNKt4l58SlZ1lBBjWCptJPRYFUp1@lvbVt2M2mtlsqsUQpaNCv6avkF "Ruby – Try It Online")
* Thanks to @Dingus suggestion to print directly instead of yielding to a return array.
* Switched to a double *#times* structure surprisingly better than *#combination*.
```
r=[]             - return array
[*1..c].combination(2) - combinations of 1..input , since a,b are coprime we don't need a==b
{|a,b|r<<[a,b,c] - we add to r the pair yelded with input attached to it
if a*a+b*b==c*c} -  if it's a valid triangle 
;r}              - finally we return r
```
[Answer]
# [R](https://www.r-project.org/), ~~71~~ 65 bytes
```
y=x=scan();while(y<-y-1)(z=(x^2-y^2)^.5)%%1||z>y&&print(c(x,y,z))
```
[Try it online!](https://tio.run/##K/r/v9K2wrY4OTFPQ9O6PCMzJ1Wj0ka3UtdQU6PKVqMizki3Ms5IM07PVFNV1bCmpsquUk2toCgzr0QjWaNCp1KnSlPzv5HpfwA "R – Try It Online")
---
Or **[R](https://www.r-project.org/) >4.1** using recursive function: **64 bytes**  
(thanks to pajonk for pointing-this out!)
```
t=\(x,y=1,z=(x^2-y^2)^.5)if(z>y){z%%1||print(c(x,y,z));t(x,y+1)}
```
[Try it online!](https://tio.run/##K/pfUpRZkJNabPu/xDatNC@5JDM/T6NCp9LWUKfKVqMizki3Ms5IM07PVDMzTaPKrlKzukpV1bCmpqAoM69EIxmkVKdKU9O6BMTSNtSshRmoYarJlZxYoqGkrKwck6ekyQUTN8chbmiMQ8LIVPM/AA "R – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~53~~ 50 bytes
```
rbind(x<-scan(),p<-combn(x,2))[,colSums(p^2)==x^2]
```
[Try it online!](https://tio.run/##K/r/vygpMy9Fo8JGtzg5MU9DU6fARjc5PzcpT6NCx0hTM1onOT8nuDS3WKMgzkjT1rYizij2v5HpfwA "R – Try It Online")
Thanks to Dominic van Essen and pajonk in the comments for some golf ideas; and thanks to Dominic van Essen and thothal for -3 bytes together.
Returns a (possibly empty) matrix with triples as columns.
Equivalent to (among others) [ovs' Gaia answer](https://codegolf.stackexchange.com/a/236401/67312).
```
x=scan()			# read input
pairs=combn(1:x,2)		# pairwise combinations of 1..x, as columns of a matrix
triple <- colSums(pairs^2)==x^2	# is it a triple?
rbind(pairs,x)[,triple]		# add a row of x's and filter the columns by the triple condition
```
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~68~~ ~~67~~ 65 bytes
```
lambda c:[(a,b,c)for a in range(1,c)if(b:=(c*c-a*a)**.5)==b//1>a]
```
[Try it online!](https://tio.run/##FcvBDsIgDADQX@FYSHXWpWpI8EfmDgVFmygjZBe/Ht31Ja9@19dSxkttPYdbf8sn3sUkP4FgxGTz0owYLaZJeT6A/qQZog@QXNqJE@vcnm0IcRjoKnPfgm5hYjwjjXhkPDESHXj2tWlZIYNa238 "Python 3.8 (pre-release) – Try It Online")
-1 by observing that `a` and `b` are never equal in a Pythagorean triple.
-2 thanks to G B, by squaring by self-multiplying.
[Answer]
# [JavaScript (V8)](https://v8.dev/), 55 bytes
Prints the triples.
```
n=>{for(q=n;p=--q;)for(;--p;)p*p+q*q-n*n||print(p,q,n)}
```
[Try it online!](https://tio.run/##TYuxDoIwFEV3v6KDQ4uvRDRVk6ZsfgUhoSGiEPL6CoQF@u21bi4nOSf3Dna1czv1tMj1ETsT0ZRb5ybuDWoyUnotfqqlJC0oo5PPvMQM952mHhdO4AFFiJWCOxRXuCi4KSiKs6oPeXo@bfvhyEzJNtY6nN34ykf35k2VIjtuGOpGaNZxTPwfJA0ifgE "JavaScript (V8) – Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), ~~20~~ ~~18~~ 16 bytes
```
^₂~+Ċ√ᵐℕ₁ᵐ≤₁,?ẉ⊥
```
Outputs one triple per line. [Try it online!](https://tio.run/##SypKTM6ozMlPN/r/P@5RU1Od9pGuRx2zHm6d8Khl6qOmRhCjcwmQoWP/cFfno66l//@bmQIA "Brachylog – Try It Online")
### Explanation
```
^₂~+Ċ√ᵐℕ₁ᵐ≤₁,?ẉ⊥
^₂                 The input number squared
  ~+               is the sum of
    Ċ              a list of two elements
     √ᵐ            Get the square root of each element
       ℕ₁ᵐ         Each of those must be a natural number greater than or equal to 1
          ≤₁       and they must be sorted in ascending order
            ,?     Append the original input to that list
              ẉ    and output it with a trailing newline
               ⊥  Fail unconditionally, forcing Brachylog to backtrack and find
                   the next output
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 38 bytes
```
{,∘⍵¨k[⍸(⍵*2)=+/¨2*⍨k←∪,{⍵[⍋⍵]}¨⍳⍵ ⍵]}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/WudRx4xHvVsPrciOftS7QwPI1DLStNXWP7TCSOtR74rsR20THnWs0qkGSgAVdAOp2NpDKx71bgayFMC8/2lANVQwh@tR31SgqjQFI9P/AA "APL (Dyalog Classic) – Try It Online")
-10 thanks to @ovs!!!!
dfn, takes the hypotenuse on right
[Answer]
# [Alchemist](https://github.com/bforte/Alchemist), 179 bytes
```
_->In_n+f
f+n->f+b+c+m
f+0n->j
j+a->j+d+x
j+m+0a->k+d
k+d->k+a+x
k+0d->i
0q+b+x->e
0q+0b+e+m->q
q+e+x->q+b
q+0e->
i+0x+0e->j+Out_a+Out_" "+Out_b+Out_" "+Out_c+Out_"\n"
i+0x+e->j+e
```
[Try it online!](https://tio.run/##VYvBCsMgEETvfkXJdRCWll6999QfKAQ1hsZUQZqCf28m5tTD7r43y9iPf4e0fLfWRm0eecyY1YyszQwHj0QRWlQRlgcTKjFBaCsmxTnAMl4h5EVJYbVqEw4Sh4CkTVGFwJRPogRt1AKpnSKev220fQ@XoV/3Z/60Vx7OVi@F1m7X@w4 "Alchemist – Try It Online")
`a`, `d`, `i`, `j`, and `k` define a source of `x`, while `b`, `e`, and `q` define a sink for `x`. `m` is equal to \$b - a\$ where relevant, and the program halts when it reaches zero to avoid duplicating triples.
### Initialization
```
_->In_n+f
f+n->f+b+c+m
f+0n->j
```
Simply sets `b`, `c`, and `m` to the input, puts the sink in state `j`, and puts the source in state `0q`.
### Source
```
j+a->j+d+x
j+m+0a->k+d
k+d->k+a+x
k+0d->i
```
When the source is in state `j`, this adds \$2a+1\$ `x` atoms while incrementing \$a\$ (using up an `m`), then returns to state `i`. Whenever the source is in state `i`, it has provided a total of \$a^2\$ `x` atoms.
### Sink
```
0q+b+x->e
0q+0b+e+m->q
q+e+x->q+b
q+0e->
```
Similar to the source, but without a special `i` state. The source starts in state `0q`, and in each cycle, it uses up \$2b-1\$ `x` atoms, decrements \$b\$, and uses up an `m`. While there is no special state to denote whether the number of atoms taken is equal to \$c^2 - b^2\$, the condition `e=0` will work.
### Output
The source waits for there to be no more `x` atoms before starting another cycle; without this check, it could pass every triple without detecting them. This is the purpose of the `i` state.
```
i+0x+0e->j+Out_a+Out_" "+Out_b+Out_" "+Out_c+Out_"\n"
i+0x+e->j+e
```
When there are no more `x` atoms in the `i` state, we check whether we are actually at a triple. If we are, output the triple. Either way, move the source to the `j` state without changing anything else.
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 28 bytes
```
{+x,+(x=%+/*/2#,+:)#+&~|\=x}
```
[Try it online!](https://ngn.bitbucket.io/k#eJxLs6rWrtDR1qiwVdXW19I3UtbRttJU1larq4mxrajl4kpTN1UwVzA0VjAyVTA0NDDlwgAA6k0LqQ==)
It uses the indices of ones in an upper triangular matrix for creating all possible (a,b) pairs, then filters them based on the pythagorean condition. Prepends the hipotenuse for each pair found.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ 9 bytes
```
ŒcÆḊ=¥Ƈ;€
```
[Try it online!](https://tio.run/##AR0A4v9qZWxsef//xZJjw4bhuIo9wqXGhzvigqz///82NQ "Jelly – Try It Online")
Backport of my improved [Vyxal answer](https://codegolf.stackexchange.com/a/236384/78410) to use pairs without replacement. -1 byte because I just realized there's a 2-byte norm built-in that saves a square. Passes all small test cases and moderately large ones (like 850) but 1105 times out, and might not work for larger inputs due to floating-point errors.
### How it works
```
ŒcÆḊ=¥Ƈ;€   Monadic link; Input = n, the hypotenuse
Œc          Pairs of 1..n without replacement
  ÆḊ=¥Ƈ     Filter those whose norm (sqrt of self-dot-product) equals n
       ;€   Append n to each pair
```
---
# [Jelly](https://github.com/DennisMitchell/jelly), 11 bytes
```
R²+²)=²ŒṪ;€
```
[Try it online!](https://tio.run/##AR8A4P9qZWxsef//UsKyK8KyKT3CssWS4bmqO@KCrP///zI1 "Jelly – Try It Online")
### How it works
```
R²+²)=²ŒṪ;€   Monadic link; Input = n, the hypotenuse
    )         For each number i of 1..n,
R²+²            collect the values of j^2+i^2 for j in 1..i
     =²ŒṪ     Coordinates (i,j) where j^2+i^2 = n^2
              (only gives the coordinates where i>j)
         ;€   Append n to each pair
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), 35 bytes
```
{⍵,⍨¨{⍵↑⍨2÷⍨≢⍵}⍸(⍵*2)=+/¨2*⍨∘.,⍨⍳⍵}
```
Calculates every combination of a^2 + b^2 and stores the values which add up to c^2
[Try it Online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@/@lHvVp1HvSsOrQCxHrVNBLKNDm8Hko86FwFFah/17tAA0lpGmrba@odWGGmBpDpm6IE0PerdDFLyP03hUdsEBSoZZcqVpmAOxIbGQMIIxDMDEYaGBqYA)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), ~~18~~ 17 bytes
```
²Ṅ'Ḣ₃;'∆²A;:[√⌊vJ
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C2%B2%E1%B9%84%27%E1%B8%A2%E2%82%83%3B%27%E2%88%86%C2%B2A%3B%3A%5B%E2%88%9A%E2%8C%8AvJ&inputs=7&header=&footer=)
It times out for inputs greater than 7, but the algorithm works. I can't wait to be outgolfed by anyone with greater mathematical knowledge lol ;p
*-1 thanks to @EmanresuA and their tip from [here](https://codegolf.stackexchange.com/a/235486/78850)* 
## Explained
```
²Ṅ'Ḣ₃;'∆²A;:[√⌊vJ
²Ṅ                   # from all the integer partitions of the input squared,
  'Ḣ₃;               # only keep those where the length is 2. And from those,
      '∆²A;          # only keep those where all numbers are perfect squares.
           :[        # If that isn't empty,
             √⌊vJ    # get the square root of each item, and append the hypotenuse to each sublist.
```
[Answer]
# [JavaScript (V8)](https://v8.dev/), 57 bytes
```
n=>(g=i=>(j=(n*n-++i*i)**.5)>i&&g(i,j%1||print(i,j,n)))``
```
[Try it online!](https://tio.run/##FYdBDoIwEADvvmIvQrcUYjWoiSk3X6EmECK4hGxJabiIb6/lMJOZoVmauXU0@Xy5hs4ENpXoDUUPRrDkPMtIEkpZlFhRkvSC1LDX6zo5Yr@NYkSs6@DBwKNUcFGgTwqOMc8RrQ/la@eLzrp7034Eg6ngC63l2Y7vYrS9SJ@cQgaMN@jE5h@GPw "JavaScript (V8) – Try It Online")
A quite straightforward approach.
[Answer]
# APL+WIN, 42 Bytes
Prompts for hypotenuse:
```
(((c*2)=+/¨n*2)/n←(,m∘.<m)/,m∘.,m←⍳c),¨c←⎕
```
[Try it online! Thanks to Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcQJanP5BlyPWooz3tv4aGRrKWkaattv6hFXlAhn4eUE5DJ/dRxww9m1xNfQgLSLZNeNS7OVlT59CKZBC7b@p/oH6u/2lcplxpXOZAbGgMJIxAPDMQYWhoYAoA "APL (Dyalog Classic) – Try It Online")
[Answer]
# Java, 91 bytes
```
c->{for(int i=c,j;--i>0;)for(j=i;--j>0;)if(i*i+j*j==c*c)System.out.println(j+" "+i+" "+c);}
```
[Try it online!](https://tio.run/##bVA9b4QwDJ3Lr7CY@CjoaNVWKuKWTh063Vh1SH3k5BQCIgapOvHbacIh6IAH6z079nuOEoNI1PlnorptOgZledozVansNTI1Oo1yr@2/K0LAShgDH4I0XD2w0XY0CC7BsGDbl6RFBe@a3xpt@rrsQBYTJserbLqANAMVeK/yJKHjIQ9dURVkqXKUZEARxSpSRYERhqdfw2WdNj2nVkZzpQMV@@DHNGcM83HKby5u7hYTQ0NnqK3H4MR27vL5BaK7mHCx7IJLw8FTmHt3M3pZUfa4woet/7zBLDs44paM3t4XzOrzU3cvhpvozj0IMfiv/rLQhUwFYtlygP@KO5Orh3H6Aw)
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 12 bytes
```
s¦e⁻+
┅r+¦↑⁈
```
[Try it online!](https://tio.run/##ASAA3/9nYWlh//9zwqZl4oG7KwrilIVyK8Km4oaR4oGI//82NQ "Gaia – Try It Online")
```
s¦e⁻+    -- helper function; check whether 3 numbers form a pythagorean triple
s¦       -- square each number            -> [a^2 b^2 c^2]
  e      -- dump all values on the stack  -> a^2 b^2 c^2
   ⁻+    -- subtract and add              -> a^2+(b^2-c^2)
┅        -- range from 1 to input
 r       -- all pairs of values from this list
  +¦     -- append the input to each pair
    ↑⁈   -- Reject; Only keep elements where the above function returns 0
```
[Answer]
# TI-Basic, 34 bytes
```
Prompt C
For(A,1,C/√(2
√(C²-A²
If not(fPart(Ans
Disp {A,Ans,C
End
```
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~99~~ \$\cdots\$ ~~75~~ 74 bytes
```
a;b;f(c){for(b=c;a=--b;)for(;--a;)c*c-b*b-a*a||printf("%d,%d,%d ",a,b,c);}
```
[Try it online!](https://tio.run/##dZThbpswEMe/5ykspEpAjArGNlAv2odpT9FEFTjQodC0SiItWsqrLztjcBzqRSE53/18d/8DIyPZlfvX67UUlWh8GVya94NfraQoV1FUiUAtRRSVIpChjKqwisqw/Pz8OLT7U@N7D1s8fJGHS1xhGYj@ChH0VrZ7P0CXBYKPcpzq4@n4vEErdGEYJTFcKUYEbK7WScx6YeD6/FHLU719SfQOIClGToJoguMcJ7ELSG9FiSrqYqhmMmiI6qYSuEisbBfPNJ9w6D7VCgYlsbZT8DE@2gXYRNmuRFwnotkwAqoHocajZxIbBy@UtyCTg3AFx1lqHBkZHMnkoIOMmJgclOfKERuCqViRMbPmECqYqcEy0FBQU4IrrXluusxUfzkz@zMKoTzJ5rczNHq12tvdxdZ9tOzUsqllM8vmjnF2Ov@x/VO/N/6tTPA4ukLLh@cYcWAkwGjOpQ4udXDUwdGvZZkDY4503MHxYJyC/FUeQvit5a4@6Cl46/NPsj4XP@BiHkb2OvXGfXC6ka9G2O639Rm2xWI0v80b@Fo@EGi5HOjpoJvDDpn0gR/CG2Gi5r0R5dsneGmgU3ALNr690k8OZDJPzzyZKtVZQPffcuv9xEBRu@Kkf6e170B3B3/LVWpruh/VOCZA02ECc/JO5/FhCyrb7x72njyw6ufdst1YLahPv3Dtveu0d2ia4v2iv/6VTVe@Hq/R738 "C (clang) – Try It Online")
*Saved a byte thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!*
Inputs integer \$c\$ and outputs all unique Pythagorean triples with hypotenuse \$c\$. The side lengths are separated by commas and the Pythagorean triples separated by spaces.
[Answer]
# Kotlin, 83 bytes
`fun x(c:Int){for(i in 1..c)for(j in 1..i)if(i*i+j*j==c*c)print("[${j} ${i} ${c}]")}`
[Try it online!](https://tio.run/##y84vycnM@59WmqeQm5iZp5FYlF5s5VhUlFhpE1xSlJmXbqdZDZat0Ei28swr0axOyy/SyFTIzFMw1NNL1gTxsqC8TM3MNI1MrUztLK0sW9tkrWTNAqAJJRpK0SrVWbUKKtWZICK5NlZJs/Z/hYahoYGppjVX7X8A "Kotlin – Try It Online")
[Answer]
# [Raku](http://raku.org/), 45 bytes
```
{grep *²+*²==*²,flat .&combinations(2)X$_}
```
[Try it online!](https://tio.run/##DcTNCYAgAAbQVT4ipD@ECuuSzdEtLDKESlEvES3VCC1mHd4zi92asJ8gEjxcq10MsvfJf5z/FXITHpTMep/UIbzSh0uqdIjHOzhxIopH8B4XJZKuyvk7gtQWHUOLskbF0LA@fA "Perl 6 – Try It Online")
* `$_` is the hypotenese length, the argument to the function.
* `.&combinations(2)` is a list of all two-element combinations of the list of integers from zero to one less than the hypoteneuse. These are the possible triangle leg lengths. (The unusual syntax `.&` means to call the global function named `combinations`, passing `$_` as the first parameter. It saves a few bytes here.)
* `X $_` pastes the hypoteneuse onto the end of each combination using the cross-product operator `X`.
* `flat` flattens the list.
* `*² + *² == *²` is an anonymous function that returns true if the sum of the squares of its first two arguments is equal to the square of the third argument.
* `grep` consumes three elements at a time from the flattened list of side lengths (since its test function takes three arguments) and returns the triples that describe a right triangle.
[Answer]
# [Swift](https://swift.org/), 87 bytes
```
let p={n in(1...n).reduce(into:[]){for j in $1...n{if $1*$1+j*j==n*n{$0+=[[$1,j,n]]}}}}
```
Using the `reduce` instead of the outer `for` loop to save the bytes needed to declare the result variable, and to return it.
[Try it online!](https://tio.run/##HYvLCoAgFAV/xYULX0gXahP4JeKqFJS4iRktpG836awGZs71xFDn3g9fSTYNSUQGWmvkuvj93jyLWM/VOt7CWUgantA/aDEMEhRkEskYFNjoJI21FFRS6Nw71nMZf5YZwLRw3j8 "Swift – Try It Online")
[Answer]
# Excel, 86 bytes
```
=LET(a,SEQUENCE(A1/2^0.5),b,(A1^2-a^2)^0.5,CONCAT(IF(MOD(b,1),"",a&","&b&","&A1&"
")))
```
[Link to Spreadsheet](https://1drv.ms/x/s!AkqhtBc2XEHJnQE2CBwPRxunPfHc?e=iLvX1g)
a equals the sequence of numbers up to the hypotenuse / \$\sqrt2\$.
b equals the list of numbers that makes a Pythagorean triple with the corresponding number in a.
If mod(b,1) = 0 then return the triple otherwise return blank.
[Answer]
# [Julia](https://julialang.org), 48 bytes
```
~c=[[a,b,c] for b=1:c for a=1:b if a^2+b^2==c^2]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700qzQnM3HBgqWlJWm6FjcN6pJto6MTdZJ0kmMV0vKLFJJsDa2SwaxEICtJITNNITHOSDspzsjWNjnOKBaqz9qhOCO_XKHOlAvKMIcxDI1hLCO4pBmcZWhoYAoxAuYEAA)
Another variation turns out to be a byte longer:
```
~c=[[a,b,c] for b=1:c,a=1:c if a<b&&a^2+b^2==c^2]
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 47 bytes
```
Cases[Range@#~Subsets~{2},x_/;x.x==#^2:>{x,#}]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@985sTi1ODooMS891UG5Lrg0qTi1pLiu2qhWpyJe37pCr8LWVjnOyMquukJHuTZW7X9AUWZeSbSyjoKSgq6dgpKOQlq0cmysmoK@g0K1qY6CuY6CobGOghGQaQbEhoYGprX/AQ "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 22 bytes
```
ɾ:vɾZƛ÷v";f2ẇ'²∑⁰²=;vJ
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=%C9%BE%3Av%C9%BEZ%C6%9B%C3%B7v%22%3Bf2%E1%BA%87%27%C2%B2%E2%88%91%E2%81%B0%C2%B2%3D%3BvJ&inputs=5&header=&footer=)
What a horrible mess. I'm sure there's so many shorter ways of doing this...
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 14 bytes
```
L2.ÆʒnOInQ}εIª
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fx0jvcNupSXn@nnmBtee2eh5a9f@/kSkA "05AB1E – Try It Online")
Second solution, just replace some boilerplate with sleek `2.Æ` (pairs without replacement), also this one is both the shortest and fastest among three
# [05AB1E](https://github.com/Adriandmen/05AB1E), 14 bytes (Thanks to @ovs)
```
Lã€{ÙʒnOtQ}εIª
```
[Try it online!](https://tio.run/##ASEA3v9vc2FiaWX//0zDo@KCrHvDmcqSbk90UX3OtUnCqv//MjU "05AB1E – Try It Online")
# [05AB1E](https://github.com/Adriandmen/05AB1E), 14 bytes
```
nÅœ2ùʒÅ²P}tεIª
```
[Try it online!](https://tio.run/##ASEA3v9vc2FiaWX//27DhcWTMsO5ypLDhcKyUH10zrVJwqr//zU "05AB1E – Try It Online")
This is slower, but 2 bytes shorter.
```
n       # square
Åœ      # integer partitions
2ù      # keep length 2s
ʒ       # filter by
Å²      # perfect square?
P       # product
}       # end filter
t       # root
ε       # foreach
I       # input
ª       # tuck
```
# [05AB1E](https://github.com/Adriandmen/05AB1E), 16 bytes
```
LDâ€{ÙʒnOInQ}εIª
```
[Try it online!](https://tio.run/##ASMA3P9vc2FiaWX//0xEw6Ligqx7w5nKkm5PSW5Rfc61ScKq//8yNQ "05AB1E – Try It Online")
The most obvious approach
```
L       # 1..n
D       # dup
â       # cartesian product
€       # vectorize
{       # sort
Ù       # nub
ʒ       # filter by
n       # square each
O       # sum
I       # input
n       # squared
Q       # equals?
}       # end filter
ε       # foreach
I       # input
ª       # append
```
]