Jump to content

Special pythagorean triplet: Difference between revisions

Realize in F#
m (→‎{{header|REXX}}: further optimized the DO loops.)
(Realize in F#)
Line 57:
</pre>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>
// Special pythagorean triplet. Nigel Galloway: August 31st., 2021
let rec fN i g e l=if g=i then None else match compare(e+g*g)(l*l) with 0->Some(i,g,l) |1->fN i (g-1) e (l+1) |_->None
seq{1..332}|>Seq.choose(fun n->let g=(999-n)/2 in fN n g (n*n) (1000-n-g))|>Seq.iter(fun(n,g,l)->printfn $"%d{n*n}(%d{n})+%d{g*g}(%d{g})=%d{l*l}(%d{l})")
</lang>
{{out}}
<pre>
40000(200)+140625(375)=180625(425)
</pre>
=={{header|Go}}==
{{trans|Wren}}
2,172

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.