📜  树递归函数 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:23.109000             🧑  作者: Mango

代码示例1
>>> def count_partitions(n, m):
        """Count the ways to partition n using parts up to m."""
        if n == 0:
            return 1
        elif n < 0:
            return 0
        elif m == 0:
            return 0
        else:
            return count_partitions(n-m, m) + count_partitions(n, m-1)