![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
m0_60006526
这个作者很懒,什么都没留下…
展开
-
2021-07-11
递归实例应用五:字符串反转,逐行输出 def spell(txt): if txt == "" or len (txt) == 0: return txt else: print (txt[-1]) return spell(txt[:len(txt)-1]) txt = input() spell(txt)原创 2021-07-11 09:51:44 · 44 阅读 · 0 评论 -
2021-07-11
递归实例应用二:求阶乘 def factorial(x): if x == 1: #出口是1!=1 return 1 else: return x * factorial(x-1) print(factoria(input()) 递归实例应用三:斐波那契 def fib(x): if x ==0 or x ==1: #首两位决定后面数值 return 1 else: return fib(x-1)+fib(x-2) print(input()) 递归实例应用四:求乘方 def power (x,y原创 2021-07-10 22:22:45 · 71 阅读 · 0 评论 -
2021-07-10
递归实例应用一: The given code defines a recursive function convert(), which needs to convert its argument from decimal to binary. 利用递归函数将十进制数字转换成二进制表示: def convert(num): if num == 0 : #base case (exit condition) return 0 else: #self-reference原创 2021-07-10 21:45:19 · 42 阅读 · 0 评论