Factorial of a number in Python
Hello Everyone,
In this post i am gonna discuss about how to write a Python program to know the factorial of the given number.
Program:
# Factorial of given number using Python
c=int(input("enter the number"))
a=1;
for a in range(1,c+1):
a=a*c
print ("factorial of ",c,"is",a)
Here we declare the input c as integer.In this program we use a for loop for getting the factorial value.
range() is defined function in Python.the above for loop is like enhanced for loop in Java.
The Output for this is,
Here is the same program in Java,
http://vitaminj.kittu.xyz/2017/12/factorial-of-agiven-number.html
In C language,
http://vitaminc.kittu.xyz/2017/12/factorial-of-number.html
Stay tuned for more interesting topics,
Thanks
In this post i am gonna discuss about how to write a Python program to know the factorial of the given number.
Program:
# Factorial of given number using Python
c=int(input("enter the number"))
a=1;
for a in range(1,c+1):
a=a*c
print ("factorial of ",c,"is",a)
Here we declare the input c as integer.In this program we use a for loop for getting the factorial value.
range() is defined function in Python.the above for loop is like enhanced for loop in Java.
The Output for this is,
Here is the same program in Java,
http://vitaminj.kittu.xyz/2017/12/factorial-of-agiven-number.html
In C language,
http://vitaminc.kittu.xyz/2017/12/factorial-of-number.html
Stay tuned for more interesting topics,
Thanks

Comments
Post a Comment