Special pythagorean triplet: Difference between revisions

added AWK
(→‎{{header|Common Lisp}}: Added more conventional implementation.)
(added AWK)
Line 73:
a + b + c = 1000
a * b * c = 31875000
</pre>
=={{header|AWK}}==
<lang AWK>
# syntax: GAWK -f SPECIAL_PYTHAGOREAN_TRIPLET.AWK
# converted from FreeBASIC
BEGIN {
main()
exit(0)
}
function main(a,b,c, limit) {
limit = 1000
for (a=1; a<=limit; a++) {
for (b=a+1; b<=limit; b++) {
for (c=b+1; c<=limit; c++) {
if (a*a + b*b == c*c) {
if (a+b+c == limit) {
printf("%d+%d+%d=%d\n",a,b,c,a+b+c)
printf("%d*%d*%d=%d\n",a,b,c,a*b*c)
return
}
}
}
}
}
}
</lang>
{{out}}
<pre>
200+375+425=1000
200*375*425=31875000
</pre>
 
477

edits