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 all numbers from 1 to ‘N’.
For Example:
Consider if ‘N’ = 4, the Factorial of 4 will be the product of all numbers from 1 to 4, which is 1 * 2 * 3 * 4 = 24. Hence, the answer is 24.
Input Format:
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first and only line of each test case contains one single integer ‘N’ representing the given integer.
Output Format:
For each test case, print the value of factorial of ‘N’.
Print the output of each test case in a separate line.
Constraints:
1 <= T <= 10
1 <= N <= 100
Time limit: 1 sec
CodingNinjas
author
2y
Factorial can be calculated using following recursive formula :
n! = n * (n-1)!
n! = 1 if n = 0 or n = 1
Factorial can also be calculated iteratively as recursion can be costly for large numbers.
Facto...read more
CodingNinjas
author
2y
Using Linked List
In this approach, we will calculate the factorial of the given number and store it in the form of a Linked List of digits named digits. To do this, we will define a function multiply...read more
CodingNinjas
author
2y
Using An Array
In this approach, we will calculate the factorial of the given number and store it in the form of an array of digits named digits. To do this, we will define a function multiply(digits, ...read more
arbindkumarsingh
4mo
works at
24
Anonymous
4mo
24
Anonymous
8mo
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 Tech Mahindra Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in Tech Mahindra Software Engineer
>
Tech Mahindra Software Engineer Interview Questions
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