MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / factorial

Function factorial

Python/5 recusrion problems.py:3–8  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

1# 1..TO FIND FACTORIAL OF A NUMBER USING RECURSION
2
3def factorial(n):
4 assert n>=0 and int(n)==n , "the number must be positive integer only"
5 if n==0 or n==1:
6 return 1
7 else:
8 return n*factorial(n-1)
9
10print(factorial(4))
11

Callers 2

pascaltriangle.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected