Project Euler #9 in Swift - Special Pythagorean triplet
Your program is quite fast, but that is a bit of a lucky coincidence. The 
Pythagorean triplet with sum 1000 is (200, 375, 425). This is not a primitive
Pythagorean triplet  but (8, 15, 17) multiplied by 25.

So your program finds (8, 15, 17) quickly and from there "jumps" to the solution.
That is fine and solves the Project Euler problem. But if you want a solution
for arbitrary sums then one can do better. On my computer, your program
needs


0.0004 seconds to find the solution for sum = 1000, but
0.014 seconds to find the solution for sum = 928, and
1.9 seconds to find that there is no solution for sum = 1001.


The key point is that your method uses three nested loops, which is not necessary
because only two of the variables a, b, c can be chosen freely and the last
is determined by \$ a+b+c = \text{sum} \$.

From the condition a &lt; b &lt; c one can also restrict the possible ranges.
If we start with a in the outermost loop then

$$
    \text{sum} = a + b + c \ge a + (a + 1) + (a + 2) = 3 \, a + 3 \implies a \le (\text{sum} - 3)/3
$$

and for b we have

$$
    \text{sum} = a + b + c \ge a + b + (b + 1) = a + 2 \, b + 1
    \implies b \le (\text{sum} - 1 - a)/2 \quad .
$$

So your function would be

func getSpecialPythagoreanTriplet(sum:Int) -&gt; Int {

    for var a = 1; a &lt;= (sum - 3)/3; a++ {
        for var b = a + 1; b &lt;= (sum-1-a)/2; b++ {
            let c = sum - a - b
            if a*a + b*b == c*c {
                return a*b*c
            }
        }
    }
    return -1
}


This method needs about 0.0002 seconds to find the solution (or it's non-existence) in all three test cases (sum = 1000, 928, 1001).

One note regarding your function name: It might be unclear what is "special"
in getSpecialPythagoreanTriplet().
Also the "Coding Guidelines for Cocoa" recommend the "get" prefix only for functions
that return some value indirectly. A better name for your function would
be something like

func pythagoreanTripletWithSum(sum:Int) -&gt; Int