diff --git a/maths/factorial_python.py b/maths/factorial_python.py index 6c1349fd5f4c..2496320a79f2 100644 --- a/maths/factorial_python.py +++ b/maths/factorial_python.py @@ -1,19 +1,19 @@ -"""Python program to find the factorial of a number provided by the user.""" +# Python program to find the factorial of a number provided by the user. # change the value for a different result -NUM = 10 +num = 7 # uncomment to take input from the user -# num = int(input("Enter a number: ")) +#num = int(input("Enter a number: ")) -FACTORIAL = 1 +factorial = 1 # check if the number is negative, positive or zero -if NUM < 0: - print("Sorry, factorial does not exist for negative numbers") -elif NUM == 0: - print("The factorial of 0 is 1") +if num < 0: + print("Sorry, factorial does not exist for negative numbers") +elif num == 0: + print("The factorial of 0 is 1") else: - for i in range(1, NUM + 1): - FACTORIAL = FACTORIAL * i - print("The factorial of", NUM, "is", FACTORIAL) + for i in range(1,num + 1): + factorial = factorial*i + print("The factorial of",num,"is",factorial)