Updated to use new library layout

This commit is contained in:
2021-07-14 15:38:17 -04:00
parent ad2e948a42
commit b5c1df010f
39 changed files with 316 additions and 493 deletions

View File

@@ -1,11 +1,11 @@
//ProjectEulerTS/Problems/Problem3.ts
//Matthew Ellison
// Created: 10-19-20
//Modified: 10-19-20
//Modified: 07-14-21
//The largest prime factor of 600851475143
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
Copyright (C) 2020 Matthew Ellison
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
@@ -23,8 +23,7 @@
import { Problem } from "./Problem";
import { getFactors } from "../../../Typescript/typescriptClasses/Algorithms";
import { Unsolved } from "../Unsolved";
import { getFactors } from "../../../Typescript/typescriptClasses/NumberAlgorithms";
export class Problem3 extends Problem{
@@ -51,10 +50,12 @@ export class Problem3 extends Problem{
//Start the timer
this.timer.start();
//Get all the factors of the number
this.factors = getFactors(Problem3.GOAL_NUMBER);
//The last element should be the largest factor
//Stop the timer
this.timer.stop();
@@ -69,23 +70,17 @@ export class Problem3 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The largest factor of the number ${Problem3.GOAL_NUMBER} is ${this.factors[this.factors.length - 1]}`;
}
//Returns the list of factors of the number
public getFactors(): number[]{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("factors");
return this.factors;
}
//Returns the largest factor of the number
public getLargestFactor(): number{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("largest factor");
return this.factors[this.factors.length];
}
//Returns the number for which we are getting the factor
@@ -94,6 +89,7 @@ export class Problem3 extends Problem{
}
}
/* Results:
*/