Ian Dorian Macleod
Problem 9
Problem Statement

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.

url: https://projecteuler.net/problem=9
Approach

C++ implementation

#include <stdc++.h> 
using namespace std;

int main() {
    int result = 0;

    for(int m = 2; m < 100; m++) {
        for(int n = 1; n < m; n++) {
            if ((pow(m, 2) - pow(n, 2) + 2*m*n + pow(m,2) + pow(n,2)) == 1000) {
                result = (pow(m, 2) - pow(n, 2)) * 2*m*n * (pow(m,2) + pow(n,2));
                break;
            }
        }
    }
    cout << result << endl;
    return 0;
}
You can also download the source code for this problem here and compile it on your local machine.
Further Analysis