Factorial of N numbers

Recursion DSA practice problem on Onlearn.

Difficulty: easy.

Topics: How to calculate the factorial of a number X, Mathematical Algorithms, Loops, Recursion, Time Complexity, Space Complexity, Functions, iterative algorithms, space complexity, mathematical operations, general programming, recursion, time complexity analysis, Factorials, Iterative Algorithms, Recursive Algorithms.

Factorial of a Number Problem Statement Given a positive integer \(X\), calculate its factorial. The factorial of a non negative integer \(X\), denoted by \(X!\), is the product of all positive integers less than or equal to \(X\). Formally: \(X! = X \times (X 1) \times (X 2) \times \ldots \times 1\) Input Specification The input consists of a single positive integer \(X\). Output Specification Print the factorial of \(X\). Constraints \(X\) is always a positive number. Sample Test Cases Sample Input 1 Sample Output 1 Explanation 1 \(5! = 5 \times 4 \times 3 \times 2 \times 1 = 120\) Sample Input 2 Sample Output 2 Explanation 2 \(3! = 3 \times 2 \times 1 = 6\)