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'.

AnswerBot
4d

Develop a program to compute the factorial of a given integer 'n'.

  • Create a function to calculate factorial using a loop or recursion

  • Handle edge cases such as negative input or input exceeding constrai...read more

Help your peers!
Add answer anonymously...
o9 Solutions Software Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter