Accenture Coding Question | Factorials | CodeWindow

Accenture Coding Question
Factorials

Given ‘a’ (1<=n<=100), find the factorial of ‘n’. The factorial of ‘n’ is defined as the product of all integers.
Input specification:
Input : any number ‘n’

Output Specification:
Return a string containing the factorial.

Example 1:
Input : 5

Output: 120
Explanation:
5!=5*4*3*2*1 = 120

Example 2:
Input 1: 6

Output: 720
Explanation: 6!=6*5*4*3*2*1 = 720

Solution in Python 3:

#https://codewindow.in
#join our telegram channel

n=int(input())
fact=1
for i in range(1,n+1):
    fact=fact*i;
print(str(fact))

# Telegram @codewindow

Output:

5
120
Recent Posts

Leave a Comment

Your email address will not be published. Required fields are marked *