Updated comments and made sure style was consistent

This commit is contained in:
2020-07-10 13:36:16 -04:00
parent 7257a118d4
commit c72754dcf8
65 changed files with 1160 additions and 747 deletions

View File

@@ -1,14 +1,14 @@
//ProjectEuler/C++/Headers/Problem16.hpp
//ProjectEuler/ProjectEulerCPP/Headers/Problem16.hpp
//Matthew Ellison
// Created: 09-28-18
//Modified: 07-14-19
//Modified: 07-09-20
//What is the sum of the digits of the number 2^1000?
//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) 2019 Matthew Ellison
Copyright (C) 2020 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
@@ -35,25 +35,29 @@
class Problem16 : public Problem{
private:
//Variables
//Static variables
static int NUM_TO_POWER; //The number that is going to be raised to a power
static int POWER; //The power that the number is going to be raised to
//Instance variables
mpz_class num; //The number to be calculated
int sumOfElements; //The sum of all digits in the number
public:
//Constructors
Problem16();
virtual void solve();
virtual std::string getString() const;
virtual void reset();
//Returns the number that was calculated
mpz_class getNumber() const;
//Return the sum of the digits of the number
int getSum() const;
//Operational functions
virtual void solve(); //Solve the problem
virtual void reset(); //Reset the problem so it can be run again
//Gets
virtual std::string getString() const; //Return a string with the solution to the problem
mpz_class getNumber() const; //Returns the number that was calculated
int getSum() const; //Return the sum of the digits of the number
};
/* Results:
2^1000 = 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376
The sum of the elements is 1366
It took 0.000 nanoseconds to solve this problem.
It took an average of 4.806 microseconds to run this problem over 100 iterations
*/
#endif //PROBLEM16_HPP