DEV Community

loading...

Discussion on: Coding Puzzles: Week of 4/8

Collapse
clandau profile image
Courtney

TypeScript. Great practice!

export class G964 {
    public static perimeter = (n) => {
      let fibArray : number[] = [0, 1, 1];
      for(let i=3; i<=n+1; i++) {
        fibArray[i] = fibArray[i-1] + fibArray[i-2];
      }
      return fibArray.reduce((a, b) => a + b) * 4;
    }
}