Write a program to find the factorial of a number in python
Answers
Answered by
4
Answer:
The given códe is written in Python 3.
n=int(input("Enter a number: "))
f=1
for i in range(2,n+1):
f=f * i
print("Factorial:",f)
Logic:
- Enter the number, say n.
- Initialise f = 1
- Loop through numbers in the range - 2 to n.
- Multiply f with each numbers in the range.
- Result obtained after termination of loop equal to the factorial of the number.
- Display the factorial.
See the attachment for output.
•••♪
Attachments:
Answered by
3
Answer:
n=(int)(input("Enter a number:-"))
f=1
for I in range(1,n+1,1):
f * =I
print("Factorial",f)
•Output Attached
Attachments:
Similar questions
Math,
3 days ago
Business Studies,
3 days ago
Hindi,
3 days ago
Math,
6 days ago
English,
7 months ago
Psychology,
7 months ago
English,
7 months ago