-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursion.py
More file actions
58 lines (43 loc) · 789 Bytes
/
recursion.py
File metadata and controls
58 lines (43 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# loop - for, while
# function - return keyword
# stack
# def func(a, b):
# print(a+b)
#
# x = func(5,6)
# print(x)
# def fact(n):
# if n==1:
# return 1
# else:
# return n*fact(n-1)
#
# print(fact(5))
def nums(n, l=None):
if n == 0:
return 0
elif l is not None:
l.append(n)
n = nums(n-1, l)
print(n)
return n
# return nums(n-1, l)
else:
l = []
l.append(n)
return l, nums(n-1,l)
l1, _ = nums(5)
# print(f"l1: {l1}")
# print(f"_: {_}")
# print(f"l: {l}")
# def count_z(num):
# if num==0:
# return 0
# elif num%10==0:
# return 1+count_z(num//10)
# else:
# return count_z(num//10)
#
#
# n = 200000526803245002
# print(count_z(n))