Right angle triangle
Lesson 16 of 20 in Coddy's Mathematical Riddles course.
A Pythagorean triplet {a, b, c} forms right angle triangle.
The perimeter, p, of a right angle triangle with integer length sides, {a, b, c}, is the sum, p = a+b+c.
Examples:
- {3, 4, 5} with p = 12,
- {30, 40, 50}, {20, 48, 52}, {24, 45, 51} with p = 120.
Challenge
MediumThere exists exactly one Pythagorean triplet for which a + b + c = 1000.
Write a function calcSpecialPythagoreanTriplet that return a list with this triplet.
Try it yourself
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "solution.h"
int main() {
int rs = 0;
int* r = calcSpecialPythagoreanTriplet(&rs);
for (int i = 0; i < rs; i++) {
if (i > 0) printf(" ");
printf("%d", r[i]);
}
printf("\n");
return 0;
}