Updated algorithms

This commit is contained in:
2021-05-28 16:13:22 -04:00
parent 3e82e69708
commit c2f9753b83
2 changed files with 4 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ private:
static uint64_t POWER_RAISED; //This is the power that the digits are raised to
//Instance variables
std::vector<uint64_t> sumOfFifthNumbers; //This is a vector of the numbers that are the sum of the fifth power of their digits
uint64_t sum; //This is the sum of the sumOfFifthNumbers vector
//Functions
std::vector<uint64_t> getDigits(uint64_t num); //Returns a vector with the indivitual digits of the number passed into it

View File

@@ -80,6 +80,8 @@ void Problem30::solve(){
}
}
sum = getSumOfList();
//Stop the timer
timer.stop();
@@ -99,7 +101,7 @@ std::string Problem30::getResult(){
throw Unsolved();
}
std::stringstream result;
result << "The sum of all the numbers that can be written as the sum of the fifth powers of their digits is " << getSumOfList();
result << "The sum of all the numbers that can be written as the sum of the fifth powers of their digits is " << sum;
return result.str();
}
//This returns the top number to be checked