Special pythagorean triplet: Difference between revisions

Added Easylang
No edit summary
(Added Easylang)
 
(One intermediate revision by one other user not shown)
Line 285:
</pre>
 
 
=={{header|EasyLang}}==
{{trans|11l}}
<syntaxhighlight>
for a = 1 to 1000
for b = a + 1 to 1000
c = 1000 - a - b
if a * a + b * b = c * c
print a & " " & b & " " & c
.
.
.
</syntaxhighlight>
{{out}}
<pre>
200 375 425
</pre>
 
=={{header|F_Sharp|F#}}==
Line 1,348 ⟶ 1,365:
=={{header|Wren}}==
Very simple approach, only takes 0.013 seconds even in Wren.
<syntaxhighlight lang="ecmascriptwren">var a = 3
while (true) {
var b = a + 1
Line 1,373 ⟶ 1,390:
<br>
Incidentally, even though we are '''told''' there is only one solution, it is almost as quick to verify this by observing that, since a < b < c, the maximum value of a must be such that 3a + 2 = 1000 or max(a) = 332. The following version ran in 0.015 seconds and, of course, produced the same output:
<syntaxhighlight lang="ecmascriptwren">for (a in 3..332) {
var b = a + 1
while (true) {
2,083

edits