Created
September 22, 2017 20:15
-
-
Save matinkaboli/30bb9e1bff959efa9f6efa4af1c7a033 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> | |
int pythagorean(int num) { | |
for (int i = 1; i < num; i++) { | |
for (int j = 1; j < num - 1; j++) { | |
const int k = num - i - j; | |
if ((i * i) + (j * j) == (k * k)) { | |
return i * j * k; | |
} | |
} | |
} | |
return 0; | |
} | |
int main() { | |
printf("%d\n", pythagorean(1000)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment