From 30bc9a201fced98b81b893bc43daa456ab0335bc Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Sun, 29 Mar 2020 21:20:49 -0400 Subject: [PATCH] brute force method for Euler# 09 --- project_euler/Problem 09/sol1.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 project_euler/Problem 09/sol1.c diff --git a/project_euler/Problem 09/sol1.c b/project_euler/Problem 09/sol1.c new file mode 100644 index 00000000..1893425c --- /dev/null +++ b/project_euler/Problem 09/sol1.c @@ -0,0 +1,18 @@ +#include + +int main(void) +{ + for (int a = 1; a < 300; a++) + for (int b = a+1; b < 400; b++) + for (int c = b+1; c < 500; c++) + { + if (a * a + b * b == c * c) + if (a + b + c == 1000) + { + printf("%d x %d x %d = %ld\n", a, b, c, (long int) a*b*c); + return 0; + } + } + + return 0; +} \ No newline at end of file