Created
January 30, 2017 23:59
-
-
Save thomaswpp/d2c017faa04d410c29d2cbeffed54381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int calc_mdc(int n1, int n2, int n3){ | |
int div, mdc = 1; | |
for(div = 2; div <= n1; div ++){ | |
if((n1 % div == 0) && (n2 % div == 0) && (n3 % div == 0)) | |
mdc = div; | |
} | |
return mdc; | |
} | |
int is_pitagora(int n1, int n2, int n3){ | |
int result = pow(n1, 2) + pow(n2, 2); | |
if (result == pow(n3, 2)) | |
return 1; | |
return 0; | |
} | |
int main() | |
{ | |
int n1, n2, n3, mdc, result; | |
while( scanf("%d %d %d", &n1, &n2, &n3) != EOF){ | |
result = is_pitagora(n1, n2, n3); | |
if (!result){ | |
printf("tripla\n"); | |
continue; | |
} | |
mdc = calc_mdc(n1, n2, n3); | |
if (mdc != 1) | |
printf("tripla pitagorica\n"); | |
else | |
printf("tripla pitagorica primitiva\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment