Tuesday 26 November 2013

PYTHON : Factorial of a Number

Factorial of a Number :

Here is the code for the Factorial of a number in Python code :


def Fact(n):
   if( n <= 1):
        return 1
   return n * Fact(n - 1)


val = 0
print " Enter Number To Find Its Factorial: ",
val = input()
print val, " !=", Fact(val)

Output :

Enter Number To Find Its Factorial:  3
3 ! =  6    

No comments:

Post a Comment