const factorial = (n: number) =>
        n < 0
          ? (() => {
              throw new TypeError('Negative numbers are not allowed!');
            })()
          : n <= 1
          ? 1
          : n * factorial(n - 1);
      
      Typescript language logo

      Calculate factorial

      Codiga's TypeScript Recipes

      Calculates the factorial of a number.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.