0 Members and 2 Guests are viewing this topic.
a²+b²=c²
a²+b²=c²a,b,c are all natural numbersa+b+c=200
There are actually two solutions (four if you allow a > b), so I'm going to be a smartass and give the unintended one:Spoiler For Spoiler: 0² + 100² = 100²
#include <stdio.h>int main(){ long a, b, c; long aa, bb, cc; for (a = 1; a <= 200; ++a) { aa = a*a; for (b = 1; b <= 200 - a - 1; ++b) { bb = b*b; c = 200 - a - b; cc = c*c; if (c > 0 && aa + bb == cc) printf("a=%ld b=%ld c=%ld\n", a,b,c); } } return 0;}
Here's my method and solution:Spoiler For method: First I typed this program into my computer (by hand), compiled it (by typing gcc by hand), and then ran it (again, typing the command by hand):Code: [Select]#include <stdio.h>int main(){ long a, b, c; long aa, bb, cc; for (a = 1; a <= 200; ++a) { aa = a*a; for (b = 1; b <= 200 - a - 1; ++b) { bb = b*b; c = 200 - a - b; cc = c*c; if (c > 0 && aa + bb == cc) printf("a=%ld b=%ld c=%ld\n", a,b,c); } } return 0;}Spoiler For solution: When I ran the program I got this answer:a=40 b=75 c=85a=75 b=40 c=85(one solution and the other trivial solution with A and B reversed)40^2 + 75^2 = 85^240, 75, and 85 all are natural numbers40 + 75 + 85 = 200QED. Time between reading the problem and instructing the computer how to find a solution: less than 5 minutesTime to run the program and obtain a solution: 4 millisecondsFinding a solution in less time than doing it purely by hand: priceless
Actually, that derivation took me about three minutes...EDIT: Scout, I did come up with a version done by hand.
I suppose you could do that, but it sounds really painful. At that point, I just recognized that the answer would necessarily be a natural number, so all you have to do is find a number A such that sqrt(A2+((200(A-100))/(A-200))2) is a whole number. That sounds like random guessing, but I already had a good idea of the value of A, so I really only had to deal with thirty values or so, which is easily done in your head.