Find the factorial of a given number
Write a program to use the loop to find the factorial of a given number.
The factorial (symbol: !) means to multiply all whole numbers from the chosen number down to 1.
For example: calculate the factorial of 5
5! = 5 × 4 × 3 × 2 × 1 = 120
Expected output:
120
Hint:
factorial =1to store factorial of a given numbernusing for loop andrange()function. (here, the loop will run five times becausenis 5)factorial = factorial *i)factorialSolution:
need an explanation for this answer? contact us directly to get an explanation for this answer