MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / factorial

Function factorial

maths/special_numbers/krishnamurthy_number.py:13–23  ·  view source on GitHub ↗

>>> factorial(3) 6 >>> factorial(0) 1 >>> factorial(5) 120

(digit: int)

Source from the content-addressed store, hash-verified

11
12
13def factorial(digit: int) -> int:
14 """
15 >>> factorial(3)
16 6
17 >>> factorial(0)
18 1
19 >>> factorial(5)
20 120
21 """
22
23 return 1 if digit in (0, 1) else (digit * factorial(digit - 1))
24
25
26def krishnamurthy(number: int) -> bool:

Callers 1

krishnamurthyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected