Tuesday, February 13, 2024

python program for factorial of given number.

def factorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n * factorial(n-1)

# Input: Enter the value of 'num' to calculate the factorial for a different number
num = int(input("Enter a positive Integer")) 
if(num>=0) 
result = factorial(num)
print("The factorial of {num} is: {result}")

No comments:

Post a Comment

Input and Output statements in Python

In Python, input and output are handled using built-in functions input() and print(). पायथन में, इनपुट और आउटपुट को अंतर्निहित फ़ंक्शन इनपुट...