Menu
Coddy logo textTech

Right angle triangle

Leçon 16 sur 20 du cours Énigmes mathématiques de Coddy.

Un triplet pythagoricien {a, b, c} forme un triangle rectangle. 

Le périmètre, p, d'un triangle rectangle dont les côtés ont des longueurs entières, {a, b, c}, est la somme, p = a+b+c.

Exemples :

  • {3, 4, 5} avec p = 12,
  • {30, 40, 50}, {20, 48, 52}, {24, 45, 51} avec p = 120.
challenge icon

Défi

Moyen

Il existe exactement un triplet pythagoricien pour lequel a + b + c = 1000.

Écrivez une fonction calcSpecialPythagoreanTriplet qui retourne une liste contenant ce triplet.

Essayez vous-même

#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;
}

Toutes les leçons de Énigmes mathématiques

5Diophantine Equation

IntroductionA problem

8Pythagorean triplet

IntroductionRight angle triangleCounting