This repository has been archived on 2019-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
s4-c/TP2/E1-3.c
2016-01-27 11:58:55 +01:00

25 lines
466 B
C

/* Triangles pythagoriques */
#include <stdio.h>
#include <math.h>
int main() {
long double h, a = 0;
long unsigned int n, i = 0;
printf("Combien de triplets remarquables voulez-vous ? ");
scanf("%u", &n);
do {
a++;
h = sqrt(2*pow(a, 2) + 2*a + 1);
if (h - (int) h == 0) { // Si h est un entier
printf("(%llf, %llf, %llf)\n", a, a+1, h);
i++;
}
} while (i < n);
return 0;
}