Updated to work with the new libraries

This commit is contained in:
2021-07-03 02:38:00 -04:00
parent fd54eb90d8
commit 9660fe9287
82 changed files with 794 additions and 1008 deletions

View File

@@ -1,14 +1,14 @@
//ProjectEuler/ProjectEulerCPP/headers/Problems/Problem20.hpp
//Matthew Ellison
// Created: 11-07-18
//Modified: 08-28-20
//Modified: 07-02-21
//What is the sum of the digits of 100!?
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
//This file contains a header from the gmp library. The library is used for large integers.
//You can find more information about them at https://gmplib.org/
//When compiling this file you need to have the gmp library installed as well as linking the libraries to your executable using the -lgmpxx and -lgmp flags
/*
Copyright (C) 2020 Matthew Ellison
Copyright (C) 2021 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,6 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef PROBLEM20_HPP
#define PROBLEM20_HPP
@@ -47,16 +46,18 @@ public:
virtual void solve(); //Solve the problem
virtual void reset(); //Reset the problem so it can be run again
//Gets
virtual std::string getResult(); //Return a string with the solution to the problem
virtual std::string getResult() const; //Return a string with the solution to the problem
mpz_class getNumber() const; //Returns the number 100!
std::string getNumberString() const; //Returns the number 100! in a string
uint64_t getSum() const; //Returns the sum of the digits of 100!
};
/* Results:
100! = 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
The sum of the digits is: 648
It took an average of 4.094 microseconds to run this problem over 100 iterations
*/
#endif //PROBLEM20_HPP
#endif //PROBLEM20_HPP