get the factorial of a number on python
fac=1 num=6 for i in range(6,0,-1): fac=fac*i print(fac)
Here is what the above code is Doing:
1. We are creating a variable called fac and assigning it a value of 1.
2. We are creating a variable called num and assigning it a value of 6.
3. We are creating a for loop that will run from 6 to 0, decreasing by 1 each time.
4. We are creating a variable called i and assigning it a value of 6.
5. We are creating a variable called fac and assigning it a value of fac * i.
6. We are printing the value of fac.