
Asked in Tech Mahindra
Factorial Calculation Problem
Given an integer N
, calculate and print the factorial of N
. The factorial of a number N
is defined as the product of all positive integers up to N
.
Example:
Input:
N = 4
Output:
24
Explanation:
The factorial of 4 is the product of 1 * 2 * 3 * 4 = 24.
Constraints:
1 ≤ T ≤ 10
1 ≤ N ≤ 100
- Time limit: 1 sec
Input:
The first line of input contains an integer,T
, the number of test cases.
For each test case, a single line contains an integerN
.
Output:
Print the factorial of N
for each test case on a separate line.

AnswerBot
4mo
Calculate and print the factorial of a given integer N.
Iterate from 1 to N and multiply each number to calculate factorial.
Handle edge cases like N=0 or N=1 separately.
Use recursion to calculate facto...read more

arbindkumarsingh
11mo
student at
XIBmS
24
Anonymous
11mo
24
Anonymous
1y
inTech Mahindra,Software Engineer Find Factorial of a Number. You are given an integer ‘N’. You have to print the value of Factorial of ‘N’. The Factorial of a number ‘N’ is defined as the product of ...read more
Add answer anonymously...
Top Software Engineer Interview Questions Asked at Tech Mahindra
Q. How do you train a machine?
Q. What are the key concepts of Object-Oriented Programming, and why are they used?
Q. What is the difference between String and StringBuilder, and in what circumstanc...read more
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for Tech Mahindra Software Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

