Write program to
find the factorial of a given number
Input N=5 then Output
5*4*3*2*1 =120
Answers
Answered by
2
Answer:
n=int(input("enter no."))
f=1
for i in range(1,n+1):
f=f*i
print("factorial of number is",f)
Answered by
1
The given python program iteratively finds the factorial of the number given as input.
Explanation:
- The given snippet firstly takes the number as input whose factorial is required.
- Then the variable f is declared and initialized to 1.
- Then the factorial is found out by iteratively multiplying the numbers.
- Finally, after the iteration is completed, the final result is stored in the variable f.
- The result is then displayed using the print command.
n = int ( input ( " enter no. " ) )
- The image of the output given by the above snippet is attached below.
Attachments:
Similar questions