a^2 + b^2 = c^2

For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.

Find the product abc.

- Code: Select all
`: pe009 ( -- n ) : Returns product`

{

| a b c |

1000 loop: a [

a 1 + 1000 for: b [

a sq b sq + sqrt dup asInteger dup ->c == ifFalse: [ continue ]

a b + c + 1000 == ifTrue: [ a b * c * return ]

]

]

}