编辑代码

def recursive_display1(n):
    if n > 1:
        recursive_display1(n - 1)
    for i in range(1, n + 1):
        print(f"{n}\t", end="")
    print()

def iterative_display(n):
    for i in range(1, n + 1):
        for j in range(1, i + 1):
            print(f"{i}\t", end="")
        print()

if __name__ == "__main__":
    print("递归解法:")
    recursive_display1(10)

    print("非递归解法:")
    iterative_display(11)