Skip to content

Commit 1fc36ec

Browse files
Create pattern_01n.py
1 parent ef548a7 commit 1fc36ec

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

function/recursion/pattern_01n.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def f(n):
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)
10+
g(n)
11+
print()
12+
n=int(input('enter a number: '))
13+
f(n)
14+
'''
15+
output:
16+
enter a number: 7
17+
1
18+
1 2
19+
1 2 3
20+
1 2 3 4
21+
1 2 3 4 5
22+
1 2 3 4 5 6
23+
1 2 3 4 5 6 7
24+
'''

0 commit comments

Comments
 (0)