Given a number, N, find the factorial of that number. N! (read as 'N' factorial) is represented by N x (N-1) x (N-2) x (N-3) x (N-4) x (N-5)....x 1
Example:
6! = 6 * 5 * 4 * 3 * 2 * 1
= 720
Input:
5
Output:
120
Python Implementation:
Using library function:
Example:
6! = 6 * 5 * 4 * 3 * 2 * 1
= 720
Input:
5
Output:
120
Python Implementation:
# Python program to find factorial of a number from math import factorial input = int(raw_input()) print factorial(input)
Without using library function:
# Python program to find factorial of a number input = int(raw_input()) factorial = 1 while input > 1: factorial = factorial * input input = input - 1 print factorial