Reply to comment

Factorial Program in Python

The factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 6! = 1 x 2 x 3 x 4 x 5 x 6 = 720. Below is a python program to identify this number.

 n = input("enter positive integer:")
if n < 0:
        print "error: you entered negative integer"
else:
        product = 1
        for i in range(1, n+1):
                product = product * i
        print n, "!=", product

 

ouput

Factorial Number - Python Programming

Reply

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.