aboutsummaryrefslogtreecommitdiff
path: root/julia/009-special_pythagorean_triplet.jl
blob: 6723e663840fdf5f6fe7804444175fd91337c294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
###
# Special Pythagorean triplet
# Problem 9
#
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
#  a2 + b2 = c2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product
# abc.
###


using Base.Iterators


for c in countfrom(1), b in 1:(c - 1), a in 1:(b - 1)
    if  a ^ 2 + b ^ 2 == c ^ 2 && a + b + c == 1000
        println(a * b * c)
        break
    end
end