Skip to content

Commit a0c6f8f

Browse files
Create pattern_02_01n.py
1 parent 3a9d2bf commit a0c6f8f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

function/recursion/pattern_02_01n.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
def f(n,i):
2+
if n==0:
3+
return
4+
def g(t):
5+
if t==0:
6+
return
7+
g(t-1)
8+
print(t,end='')
9+
f(n-1,i+1)
10+
print(' '*(i-1),end="")
11+
g(n)
12+
print()
13+
n=int(input('enter a number: '))
14+
i=1
15+
f(n,i)
16+
'''
17+
output:
18+
enter a number: 6
19+
1
20+
12
21+
123
22+
1234
23+
12345
24+
123456
25+
'''

0 commit comments

Comments
 (0)