use*_*511 0 python recursion loops image
我正在使用Python,我的任务是编写一个递归循环.想法是形成一个垂直行的图片:
1st row: 1 object (2**0)
2nd row: 2 object ( 2**1)
3rd row: 4 obj (2**2)
4th: 8 obj (2**3)
Run Code Online (Sandbox Code Playgroud)
等等直到n行和n列.
通过使用"堆栈"和"旁边"函数,我需要制定该模式.
我的代码是:
def fractal(Pattern, n):
if n== 1:
return beside( Pattern, n)
else:
return beside( fractal(Pattern, n-1), fractal(Pattern, n))
Run Code Online (Sandbox Code Playgroud)
但是,当我想显示整体模式时,会出现无限循环.
| 归档时间: |
|
| 查看次数: |
399 次 |
| 最近记录: |