mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated how results are retrieved
This commit is contained in:
@@ -61,6 +61,10 @@ void Problem25::solve(){
|
||||
//Stop the timer
|
||||
timer.stop();
|
||||
|
||||
//Save the results
|
||||
result << "The first Fibonacci number with " << NUM_DIGITS << " digits is " << number
|
||||
<< "\nIts index is " << index;
|
||||
|
||||
//Throw a flag to show the problem is solved
|
||||
solved = true;
|
||||
}
|
||||
@@ -72,19 +76,6 @@ void Problem25::reset(){
|
||||
index = 2;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem25::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
throw Unsolved();
|
||||
}
|
||||
|
||||
std::stringstream results;
|
||||
results << "The first Fibonacci number with " << NUM_DIGITS << " digits is " << number
|
||||
<< "\nIts index is " << index;
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the Fibonacci number asked for
|
||||
mpz_class Problem25::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
|
||||
Reference in New Issue
Block a user