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
4mo

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!
Select
Add answer anonymously...
o9 Solutions Software Consultant Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits