mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Added solution to problem 38
This commit is contained in:
51
headers/Problems/Problem38.hpp
Normal file
51
headers/Problems/Problem38.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//ProjectEuler/ProjectEulerCPP/headers/Problems/Problem38.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 10-10-21
|
||||
//Modified: 10-10-21
|
||||
//What is the largest 1-9 pandigital number that can be formed as the concatenated product of an integer with 1, 2, ... n where n > 1
|
||||
/*
|
||||
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
|
||||
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/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include "Problem.hpp"
|
||||
|
||||
|
||||
class Problem38 : public Problem{
|
||||
private:
|
||||
//Variables
|
||||
//Static variables
|
||||
static int HIGHEST_POSSIBLE_NUM; //The highest number that needs to be checked for a 1-9 pandigital
|
||||
//Instance variables
|
||||
uint64_t largestNum;
|
||||
uint64_t pandigital;
|
||||
//Functions
|
||||
std::string executeFormula(int num); //Take the number and add its multiples to a string to return
|
||||
public:
|
||||
//Functions
|
||||
//Constructor
|
||||
Problem38();
|
||||
//Operational functions
|
||||
virtual void solve(); //Solve the problem
|
||||
virtual void reset(); //Reset the problem so it can be run again
|
||||
//Gets
|
||||
virtual std::string getResult() const; //Returns a string with the solution to the problem
|
||||
uint64_t getLargestNum() const; //Returns the largest number
|
||||
uint64_t getPandigital() const; //Returns the pandigital of the number
|
||||
};
|
||||
Reference in New Issue
Block a user