Last active
January 6, 2016 21:32
-
-
Save defacto133/85226ee99eca19dea0ab to your computer and use it in GitHub Desktop.
This file contains 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 fib_n_step_aux(n, k, memo): | |
if k <= 0: | |
return 0 | |
if k in [1, 2]: | |
return 1 | |
if k not in memo: | |
res = 0 | |
for i in range(1, n + 1): | |
res += fib_n_step_aux(n, k - i, memo) | |
memo[k] = res | |
return memo[k] | |
def fib_n_step(n, k): | |
return fib_n_step_aux(n, k, {}) | |
def f(n, m): | |
return 2**n - fib_n_step(m, n + 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment