Factorial in Typescript

Published on 02 October 2023 (Updated: 02 October 2023)

Welcome to the Factorial 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

let error_msg: string = "Usage: please input a non-negative integer"
let num_str: string = (process.argv.length == 3) ? process.argv[2] : ""
let num: number = parseInt(num_str);
if (isNaN(num) || num < 0) {
    console.log(error_msg);
    process.exit(1);
}
let factorial: number = 1;
for (let i = 1; i <= num; i++) {
    factorial *= i;
}
console.log(factorial);

Factorial in Typescript was written by:

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

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.