mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-03-30 18:36:43 +00:00
Added doctest to /maths/power_using_r
ecursion.py
This commit is contained in:
parent
e9e7c96465
commit
a2b28b4862
@ -38,6 +38,14 @@ def power(base: int, exponent: int) -> float:
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
RecursionError: maximum recursion depth exceeded
|
||||
>>> power(0, 0)
|
||||
1
|
||||
>>> power(0, 1)
|
||||
0
|
||||
>>> power(5,6)
|
||||
15625
|
||||
>>> power(23, 12)
|
||||
21914624432020321
|
||||
"""
|
||||
return base * power(base, (exponent - 1)) if exponent else 1
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user