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 =1
to store factorial of a given numbern
using for loop andrange()
function. (here, the loop will run five times becausen
is 5)factorial = factorial *i
)factorial
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer