mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//ProjectEuler/C++/Source/Problem5.cpp
|
||||
//ProjectEuler/ProjectEulerCPP/Source/Problem5.cpp
|
||||
//Matthew Ellison
|
||||
// Created: 09-28-18
|
||||
//Modified: 07-14-19
|
||||
//Modified: 07-09-20
|
||||
//What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
|
||||
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
|
||||
/*
|
||||
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
|
||||
@@ -31,9 +31,11 @@
|
||||
#include "../Headers/Problem5.hpp"
|
||||
|
||||
|
||||
//Constructor
|
||||
Problem5::Problem5() : Problem("What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?"), smallestNum(0){
|
||||
}
|
||||
|
||||
//Solve the problem
|
||||
void Problem5::solve(){
|
||||
//If the problem has already been solved do nothing and end the function
|
||||
if(solved){
|
||||
@@ -74,6 +76,13 @@ void Problem5::solve(){
|
||||
solved = true;
|
||||
}
|
||||
|
||||
//Reset the problem so it can be run again
|
||||
void Problem5::reset(){
|
||||
Problem::reset();
|
||||
smallestNum = 0;
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem5::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
@@ -84,6 +93,7 @@ std::string Problem5::getString() const{
|
||||
return results.str();
|
||||
}
|
||||
|
||||
//Returns the requested number
|
||||
int Problem5::getNumber() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
@@ -91,8 +101,3 @@ int Problem5::getNumber() const{
|
||||
}
|
||||
return smallestNum;
|
||||
}
|
||||
|
||||
void Problem5::reset(){
|
||||
Problem::reset();
|
||||
smallestNum = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user