Skip to content

Commit

Permalink
Added doctest to /maths/power_using_recursion.py (#11994)
Browse files Browse the repository at this point in the history
  • Loading branch information
Parthjhalani07 authored Dec 30, 2024
1 parent 24923ee commit da587d0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions maths/power_using_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit da587d0

Please sign in to comment.