Factorial Calculation Problem

Given an integer N, determine the factorial value of N. The factorial of a number N is the product of all positive integers from 1 to N.

Input:

First line of input: An integer 'T', the number of test cases.
Next 'T' lines: An integer 'N', representing the given number for each test case.

Output:

Output the factorial of 'N' for each test case in a new line.

Example:

Input:
T = 1
N = 4
Output:
24
Explanation:

As the factorial of 4 is 1 * 2 * 3 * 4 = 24, the output is 24.

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ N ≤ 100
  • Time limit: 1 sec
AnswerBot
4mo

Calculate factorial of a given number N.

  • Iterate from 1 to N and multiply each number to get the factorial value.

  • Handle edge cases like N=0 or N=1 separately.

  • Use recursion or iteration to calculate fac...read more

Help your peers!
Select
Add answer anonymously...

MAQ Software Software Engineer interview questions & answers

A Software Engineer was asked 10mo agoQ. Given a singly linked list, reverse the nodes of the linked list k at a time and...read more
A Software Engineer was asked 11mo agoQ. How does hashing help in identifying duplicate values?
A Software Engineer was asked Q. Given an array, reverse the order of its elements.

Popular interview questions of Software Engineer

A Software Engineer was asked 10mo agoQ1. Given a singly linked list, reverse the nodes of the linked list k at a time and...read more
A Software Engineer was asked 11mo agoQ2. How does hashing help in identifying duplicate values?
A Software Engineer was asked Q3. Given an array, reverse the order of its elements.
MAQ Software Software Engineer 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