Skip to content

Instantly share code, notes, and snippets.

@zrbecker
Created April 22, 2011 09:05
Show Gist options
  • Select an option

  • Save zrbecker/936319 to your computer and use it in GitHub Desktop.

Select an option

Save zrbecker/936319 to your computer and use it in GitHub Desktop.
Euler 9
#include <stdio.h>
#define MAX 1000
int main() {
int a, b, c;
a = 0;
b = 1;
c = MAX - a - b;
while (a < b && b < c) {
if (a * a + b * b == c * c)
break;
b++;
c--;
if (b >= c) {
a++;
b = a + 1;
c = MAX - a - b;
}
}
printf("%d^2 + %d^2 = %d^2\n", a, b, c);
printf("%d\n", a * b * c);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment