mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated algorithms
This commit is contained in:
@@ -40,6 +40,7 @@ private:
|
|||||||
static uint64_t POWER_RAISED; //This is the power that the digits are raised to
|
static uint64_t POWER_RAISED; //This is the power that the digits are raised to
|
||||||
//Instance variables
|
//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
|
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
|
//Functions
|
||||||
std::vector<uint64_t> getDigits(uint64_t num); //Returns a vector with the indivitual digits of the number passed into it
|
std::vector<uint64_t> getDigits(uint64_t num); //Returns a vector with the indivitual digits of the number passed into it
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ void Problem30::solve(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sum = getSumOfList();
|
||||||
|
|
||||||
//Stop the timer
|
//Stop the timer
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ std::string Problem30::getResult(){
|
|||||||
throw Unsolved();
|
throw Unsolved();
|
||||||
}
|
}
|
||||||
std::stringstream result;
|
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();
|
return result.str();
|
||||||
}
|
}
|
||||||
//This returns the top number to be checked
|
//This returns the top number to be checked
|
||||||
|
|||||||
Reference in New Issue
Block a user