Tech Study

Write a Python function to calculate the factorial of a number

Introduction

Write a Python function to calculate the factorial of a number. I have used python 3.7 compiler for debugging purpose.

def factorial(num):
    if num == 0:
        return 1
    else:
        return num * factorial(num-1)
num=int(input("Input a number to compute the factiorial : "))
print(factorial(num))

Result

Write a Python function to calculate the factorial of a number
Write a Python function to calculate the factorial of a number

TaggedWrite a Python function to calculate the factorial of a number

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more