用python写一个1+(1+2)+(1+2+3)+...+(1+2+3+...+n)的一个代码实在不懂的是怎么弄x一直变大
def custom(n: int): if n == 1: return "1" else: return custom(n - 1) + "+" + f"({'+'.join([str(i) for i in range(1, n + 1)])})" print(custom(5))
初步看用递归好实现