Skip to content

Commit

Permalink
Create factorial
Browse files Browse the repository at this point in the history
  • Loading branch information
MithraSan authored Oct 15, 2023
1 parent 52d62ac commit cce6706
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions factorial
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)

# Example usage:
number = 5
result = factorial(number)

print(f"The factorial of {number} is {result}.")

0 comments on commit cce6706

Please sign in to comment.