Fibonacci in Typescript

Published on 28 April 2022 (Updated: 02 February 2023)

Fibonacci in Typescript

Welcome to the Fibonacci in Typescript page! Here, you’ll find the source code for this program as well as a description of how the program works.

Current Solution

function fibonacci(num: number) {

  let n = Number(num);
  let elementOne: number = 0;
  let elementTwo: number = 1;
  let result: number = 0;

  for (let i: number = 1; i <= n; i++) {
    result = elementOne + elementTwo;
    elementOne = elementTwo;
    elementTwo = result;
    console.log(`Index: ${i}: ${elementOne}`);



Fibonacci in Typescript was written by:

If you see anything you’d like to change or update, please consider contributing.

Note: The solution shown above is the current solution in the Sample Programs repository as of Oct 12 2018 11:24:37. The solution was first committed on Oct 12 2018 10:16:37. As a result, documentation below may be outdated.

How to Implement the Solution

No ‘How to Implement the Solution’ section available. Please consider contributing.

How to Run the Solution

No ‘How to Run the Solution’ section available. Please consider contributing.