Sum total

in #ita2 months ago

export class Squares {

count: number;

constructor(count: number) {

this.count = count;

}

get sumOfSquares(): number {

let tot = 0;

for(let i=0; i<=this.count; i++){

  tot += i\*i;

}

return tot;

}

get squareOfSum(): number {

let tot = 0;

for(let i=0; i<=this.count; i++){

  tot +=i;

}

return tot\*tot;

}

get difference(): number {

return this.squareOfSum - this.sumOfSquares;

}

}