# 9 Special Pythagorean Triplet

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,

$$a^2 + b^2 = c^2$$ For example, $$3^2 + 4^2 = 9 + 16 = 25 = 5^2.$$

There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.

```
#include <iostream>
#include <limits>
#include <vector>
#include <math.h>

using namespace std;

void pause() { cin.ignore(numeric_limits<streamsize>::max(), '\n'); }

void practice1LoopTesting()
{
    for (int i = 0; i < 5; i++)
    {
        cout << i << ' ';
    }
}

void practice2LoopTesting()
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            cout << i << j << ' ';
        }
    }
}

void practice3LoopTesting()
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            for (int z = 0; z < 5; z++)
            {
                cout << i << j << z << ' ';
            }
        }
    }
}


int main()
{
    int a = 0;
    int b = 0;
    int c = 0;

    int sumABC = 1000;

    for (int a = 0; a < sumABC; a++)
    {
        for (int b = 0; b < sumABC; b++)
        {
            for (int c = 0; c < sumABC; c++)
            {
                // check 1
                if (a < b && b < c)
                {
                    // check 2
                    if (a*a + b*b == c*c)
                    {
                        // check 3
                        if (a + b + c == sumABC)
                        {
                            cout << a << ' ' << b << ' ' << c << ' ' << endl;
                        }
                    }

                }
            }
        }
    }

    cout << "done";



    // Practice with Combinations

    /*cout << "Single for loop: " << endl;
    practice1LoopTesting();
    cout << "\n\n";

    cout << "Double for loop: " << endl;
    practice2LoopTesting();
    cout << "\n\n";

    cout << "Triple for loop: " << endl;
    practice3LoopTesting();
    cout << "\n\n";*/

    pause();
}
```

Solution: 31875000


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maksimdan.gitbook.io/interview-practice-problems/project_eular/9_special_pythagorean_triplet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
