H = 3
count = 0

def dfs(current_height):
    global count
    
    if current_height == H:
        count += 1
        return
    
    if current_height > H:
        return
    
    dfs(current_height + 1)
    
    dfs(current_height + 2)

dfs(0)
print("총 방법의 수:", count)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: