题目:一道递归题
我扯不下去了,有人发我一道题,下面是解决办法:
代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
from icecream import ic def fun(n,num=0): if n == 1: return num if n%2==0: n = n/2 else: n = (3*n+1)/2 num += 1 return fun(n,num) ic(fun(11))
-----------------------------------------------------------------------------------------------------------------------------------------