Anonymous user
Special pythagorean triplet: Difference between revisions
m
→{{header|REXX}}: incorporated optimizations for another Rosetta Code task: Pythagorean triples, added support to (only) find 1 (or any number) of solutions.
(→{{header|PL/M}}: Tweak) |
m (→{{header|REXX}}: incorporated optimizations for another Rosetta Code task: Pythagorean triples, added support to (only) find 1 (or any number) of solutions.) |
||
Line 366:
<br>the next integer was used.
<lang rexx>/*REXX pgm computes integers A, B, C that solve: 0<A<B<C; A+B+C = 1000; A^2+B^2 = C^2 */
parse arg s hi n .
if s=='' | s=="," then s= 1000 /*Not specified? Then use the default.*/
if hi=='' | hi=="," then hi= 1000 /* " " " " " " */
if n=='' | n=="," then n= 1 /* " " " " " " */
hi2= hi-2
#= 0;
do
do
if
aabb= aa + @.b
do c=b+1
if @.c
abc= ab + c
if abc > s then iterate b
end
end
end /*a*/
done: say pad pad pad # ' solutions found.'
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: #= #
{{out|output|text= when using the default inputs:}}
<pre>
a= 200 b= 375 c= 425
1 solutions found.
</pre>
|