mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated for performance
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user