Last active
June 19, 2017 20:08
-
-
Save effective-light/9c3c0fa5a92f8e25eff4fa2abdb0408a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_exp(b: int, n: int) -> int: | |
""" | |
>>> calc_exp(10, 1) | |
21 | |
>>> calc_exp(3, 4) | |
960 | |
""" | |
def _calc_exp(p: int) -> int: | |
if p == 1: | |
return b | |
return b ** p + _calc_exp(p - 1) | |
def _calc_mul(o: int) -> int: | |
if o == 1: | |
return b + 1 | |
return (b + o) * _calc_mul(o - 1) | |
return _calc_exp(n) + _calc_mul(n) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment