diff --git a/horner.ts b/horner.ts new file mode 100644 index 0000000..9e52673 --- /dev/null +++ b/horner.ts @@ -0,0 +1,50 @@ +class Horner { + + constants: number[]; + + constructor(constants: number[]) { + this.constants = constants; + } + + candidates() { + // Not effective solution + let max = Math.abs(this.constants[0]) + Math.abs(this.constants[this.constants.length - 1]); + let min = 1; + let candidates: number[] = []; + for(let i = min; i<=max; i++) { + candidates.push(i); + candidates.push(-i); + } + return candidates; + } + + functional_value(number: number) { + let new_polynom = [this.constants[0]]; + for(let i=1; i