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,7 +1,7 @@
//ProjectEulerTS/Problems/Problem26.ts
//Matthew Ellison
// Created: 04-18-21
//Modified: 04-18-21
//Modified: 07-14-21
//Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/typescriptClasses
/*
@@ -22,7 +22,6 @@
*/
import { Unsolved } from "../Unsolved";
import { Problem } from "./Problem";
@@ -52,6 +51,7 @@ export class Problem26 extends Problem{
//Start the timer
this.timer.start();
//Start with 1/2 and find out how long the logest cycle is by checking the reainders
//Loop through every number from 2-999 and use it for the denominator
for(let denominator: number = 2;denominator <= Problem26.TOP_NUM;++denominator){
@@ -88,6 +88,7 @@ export class Problem26 extends Problem{
}
}
//Stop the timer
this.timer.stop();
@@ -103,27 +104,22 @@ export class Problem26 extends Problem{
//Gets
//Returns the result of solving the problem
public getResult(): string{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("result");
return `The longest cycle is ${this.longestCycle} digits long\nIt started with the number ${this.longestNumber}`;
}
//Returns the length of the longest cycle
public getLongestCycle(): number{
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("length of the longest cycle");
return this.longestCycle;
}
//Returns the denominator that start the longest cycle
public getLongestNumber(){
if(!this.solved){
throw new Unsolved();
}
this.solvedCheck("denominator that starts the longest cycle");
return this.longestNumber;
}
}
/* Results:
The longest cycle is 982 digits long
It started with the number 983