Skip to content

Commit dc5b236

Browse files
author
tianqing.liang
committed
递归
1 parent 3666b67 commit dc5b236

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
3. **[Dart,Python]插入排序**
88
4. **[Dart,Python]栈,队列,循环队列**
99
5. **[Dart,Python]链表,链表实现栈,链表实现队列**
10-
6. 递归
10+
6. **[Dart,Python]递归**
1111
7. **[Dart,Python]归并排序**
1212
8. **[Dart,Python]快速排序**
1313
9. **[Dart,Python]二分搜索**

python/multiSort.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def binarySearch(sortList,left,right,x):
120120
else:
121121
return -1
122122

123+
def sumNumber(n):
124+
if n == 0:
125+
return 0
126+
return n+sumNumber(n-1)
123127

124128
# 计算结果,计算时间
125129
def caculateResultAndTime(name,fuction,randomseed):
@@ -158,8 +162,10 @@ def caculateResultAndTime(name,fuction,randomseed):
158162
endTime = time.perf_counter()
159163
print("查找结果:",result,' 花费时间:',endTime-startTime)
160164
print("-------------------- 结束\n")
161-
162165

166+
print("--------------------递归函数")
167+
print('递归结果:',sumNumber(100))
168+
print("-------------------- 结束\n")
163169

164170

165171

0 commit comments

Comments
 (0)