简单递归
#coding:utf-8 def calc(n): print(n) if int(n/2)>0: return calc(int(n/2)) print("->",n)
calc(10)
结果:
C:\Users\jelena.zhao\AppData\Local\Programs\Python\Python36\python3.exe E:/pythonscripts/study/test1/test.py 10 5 2 1 -> 1 Process finished with exit code 0
可以打断点看递归的过程