From c2f9753b83e0c9559f0d7477b82edb495d9df8ac Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Fri, 28 May 2021 16:13:22 -0400 Subject: [PATCH] Updated algorithms --- headers/Problems/Problem30.hpp | 1 + src/Problems/Problem30.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/headers/Problems/Problem30.hpp b/headers/Problems/Problem30.hpp index 99cb76e..a52393a 100644 --- a/headers/Problems/Problem30.hpp +++ b/headers/Problems/Problem30.hpp @@ -40,6 +40,7 @@ private: static uint64_t POWER_RAISED; //This is the power that the digits are raised to //Instance variables std::vector 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 getDigits(uint64_t num); //Returns a vector with the indivitual digits of the number passed into it diff --git a/src/Problems/Problem30.cpp b/src/Problems/Problem30.cpp index 1d66fd5..359abcf 100644 --- a/src/Problems/Problem30.cpp +++ b/src/Problems/Problem30.cpp @@ -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