Computer Science, asked by prantkeshari677, 6 days ago

Write a program to find the factorial of a number in python​

Answers

Answered by anindyaadhikari13
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 BrainlyProgrammer
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