Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
#include <stdio.h>
#include <stdlib.h>
Functions | |
int | main (void) |
Main function. More... | |
Problem 9 solution
Problem Statement: 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.
Given \(a^2 + b^2 = c^2\) and \(a+b+c = n\), we can write:
\begin{eqnarray*} b &=& \frac{n^2 - 2an}{2n - 2a}\\ c &=& n - a - b \end{eqnarray*}
int main | ( | void | ) |
Main function.