## Euler Problem 9 Definition

A Pythagorean triple is a set of three natural numbers, , for which, . For example:

.

There exists exactly one Pythagorean triplet for which .

Find the product of *a*, *b* and *c*.

## Brute Force Solution

This solution uses brute force and checks all combinations of *a*, *b* and *c*. To limit the solution space I used the fact that *a* < *b* < *c*, which implies that *a* < *s*/3, and *a* < *b* < *s*/2, where *s* is the sum of the three sides.

a <- 0 b <- 0 c <- 0 s <- 1000 found <- FALSE for (a in 1:floor((s/3))) { for (b in a:(s/2)) { c <- s - a - b if (a^2 + b^2 == c^2) { found <- TRUE break } } if (found) break } answer <- a * b * c

View this code on GitHub.