Files
ProjectEulerCPP/Headers/Problem4.hpp

55 lines
1.6 KiB
C++

//ProjectEuler/C++/Headers/Problem4.hpp
//Matthew Ellison
// Created: 09-28-18
//Modified: 07-14-19
//Find the largest palindrome made from the product of two 3-digit numbers
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
/*
Copyright (C) 2019 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
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 PROBLEM4_HPP
#define PROBLEM4_HPP
#include <vector>
#include <string>
#include "Problem.hpp"
class Problem4 : public Problem{
private:
static int START_NUM;
static int END_NUM;
std::vector<uint64_t> palindromes; //Holds all numbers that turn out to be palindromes
public:
Problem4();
virtual void solve();
virtual std::string getString() const;
//Returns the list of all palindromes
std::vector<uint64_t> getPalindromes() const;
//Returns the largest palindrome
uint64_t getLargestPalindrome() const;
};
/* Results:
The largest palindrome is 906609
It took 31.904 milliseconds to solve this problem.
*/
#endif //PROBLEM4_HPP