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,11 +1,11 @@
//ProjectEuler/C++/Source/Problem27.cpp
//ProjectEuler/ProjectEulerCPP/Source/Problem27.cpp
//Matthew Ellison
// Created: 09-14-19
//Modified: 09-14-19
//Modified: 07-09-20
//Find the product of the coefficients, |a| < 1000 and |b| <= 1000, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n=0.
//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
@@ -28,10 +28,12 @@
#include "../Headers/Problem27.hpp"
//Constructor
Problem27::Problem27() : Problem("Considering quadratics of the form n^2 + an + b, where |a| < 1000 and |b| <= 1000, find the product of the coefficients a and b that produce the maximum number of primes for consecutive values of n starting with n = 0."){
topA = topB = topN = 0;
}
//Solve the problem
void Problem27::solve(){
//If the problem has already been solved do nothing and end the function
if(solved){
@@ -72,6 +74,14 @@ void Problem27::solve(){
solved = true;
}
//Reset the problem so it can be run again
void Problem27::reset(){
Problem::reset();
topA = topB = topN = 0;
primes.clear();
}
//Return a string with the solution to the problem
std::string Problem27::getString() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -86,6 +96,7 @@ std::string Problem27::getString() const{
return results.str();
}
//Returns the top A that was generated
int64_t Problem27::getTopA() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -94,6 +105,7 @@ int64_t Problem27::getTopA() const{
return topA;
}
//Returns the top B that was generated
int64_t Problem27::getTopB() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -102,6 +114,7 @@ int64_t Problem27::getTopB() const{
return topB;
}
//Returns the top N that was generated
int64_t Problem27::getTopN() const{
//If the problem hasn't been solved throw an exception
if(!solved){
@@ -109,9 +122,3 @@ int64_t Problem27::getTopN() const{
}
return topN;
}
void Problem27::reset(){
Problem::reset();
topA = topB = topN = 0;
primes.clear();
}