A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
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.
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(`${i}: ${elementOne}`);
}
}
let num_str = (process.argv.length >= 3) ? process.argv[2] : ""
let num: number = parseInt(num_str);
if (isNaN(num)) {
console.log("Usage: please input the count of fibonacci numbers to output")
process.exit(0)
}
fibonacci(num);
Fibonacci in Typescript was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.