@melvina
To compute Fibonacci extensions in TypeScript, you can follow these steps:
1 2 3 4 5 6 7 8 9 |
function fibonacci(n: number): number[] { if (n <= 1) { return [0, 1]; } else { const seq = fibonacci(n - 1); seq.push(seq[seq.length - 1] + seq[seq.length - 2]); return seq; } } |
1 2 3 4 5 6 7 |
function fibonacciExtensions(seq: number[], multiplier: number): number[] { const fibExtension = []; for (let i = 1; i <= 10; i++) { fibExtension.push(seq[seq.length - 1] * Math.pow(multiplier, i)); } return fibExtension; } |
1 2 3 4 5 |
const fibSequence = fibonacci(10); console.log("Fibonacci Sequence:", fibSequence); const fibExtension = fibonacciExtensions(fibSequence, 1.618); console.log("Fibonacci Extensions:", fibExtension); |
By following these steps, you can easily compute Fibonacci extensions in TypeScript.