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