Created
February 21, 2025 04:45
-
-
Save igorvanloo/967523e4820f5a17916f3daddae2798f to your computer and use it in GitHub Desktop.
p169
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
from functools import cache | |
@cache | |
def a(n): | |
if n == 0: | |
return 0 | |
if n == 1: | |
return 1 | |
if n % 2 == 0: | |
return a(n//2) | |
else: | |
return a((n - 1)//2) + a((n - 1)//2 + 1) | |
def f(n): | |
return a(n + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment