Search This Blog

Thursday, 18 November 2021

program to take input for a number calculate and display its factorial

Write a program to take input for a number calculate and display its factorial.

def fact(n):
f=1
i=1
while i<=n:
f=f*i
i=i+1
print("Factorial = ",f)
def main():
a=int(input("Enter any no "))
fact(a)
"""
if __name__=='__main__':
main()
"""
#or
#function calling
main()


Output:-
(1). Enter any no 5
Factorial = 120
(2). Enter any no 8
Factorial = 40320
(3). Enter any no 10
Factorial = 3628800

No comments:

Post a Comment

how to implement YOLOv3 using Python and TensorFlow

Object Detection with YOLOv3 Introduction YOLOv3 (You Only Look Once version 3) is a real-time object detection algorithm that can detect ob...