Skip to content

Instantly share code, notes, and snippets.

@matinkaboli
Created September 22, 2017 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matinkaboli/30bb9e1bff959efa9f6efa4af1c7a033 to your computer and use it in GitHub Desktop.
Save matinkaboli/30bb9e1bff959efa9f6efa4af1c7a033 to your computer and use it in GitHub Desktop.
#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