Factorial Calculation Problem Statement
Develop a program to compute the factorial of a given integer 'n'.
The factorial of a non-negative integer 'n', denoted as n!
, is the product of all positive integers less than or equal to 'n'.
Explanation:
The factorial is calculated as follows:
n! = n * (n-1) * (n-2) * (n-3) ... * 1
Print the factorial of the given number 'n'. If the factorial is undefined, print 'Error'.
Input:
The only line of input contains a single integer.
Output:
The only line of output should display the factorial of the number or "Error" if it cannot be calculated.
Example:
Input:
5
Output:
120
Constraints:
- -10 <= n <= 12
Note:
The factorial is only defined for non-negative integers. Values of 'n' less than 0 should return 'Error'.
Be the first one to answer
Add answer anonymously...
Top Paytm Full Stack Developer interview questions & answers
Popular interview questions of Full Stack Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app