mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-18 08:17:01 +00:00
Added doctest to /maths/power_using_recursion.py (#11994)
This commit is contained in:
parent
24923ee635
commit
da587d06ac
|
@ -38,6 +38,14 @@ def power(base: int, exponent: int) -> float:
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
RecursionError: maximum recursion depth exceeded
|
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
|
return base * power(base, (exponent - 1)) if exponent else 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user