Updated for performance

This commit is contained in:
2020-06-15 20:06:52 -04:00
parent 4262dd5cf5
commit db74198956
2 changed files with 3 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ public:
/* Results:
The Pythagorean triplet is 200 375 425
The numbers' product is 31875000
It took 146.100 microseconds to solve this problem.
It took 0.000 nanoseconds to solve this problem.
*/
#endif //PROBLEM9_HPP

View File

@@ -45,12 +45,12 @@ void Problem9::solve(){
//Loop through all possible a's
while((a < 1000) && !found){
b = a + 1; //b bust be greater than a
c = sqrt(pow(a, 2) + pow(b, 2));
c = sqrt((a * a) + (b * b));
//Loop through all possible b's
while((a + b + c) < 1000){
++b;
c = sqrt(pow(a, 2) + pow(b, 2));
c = sqrt((a * a) + (b * b));
}
//If the sum == 1000 you found the number, otherwise go to the next possible a