递归
#递归算法 def calc(n): print(n) if n/2 >1: res= calc(n/2) print(‘res:‘,res) print(‘N:‘,n) return n calc(10) """ #斐波那契 alex def func(arg1,arg2,stop): if arg1 ==0: print(arg1,arg2) arg3=arg1+arg2 print(arg3) if arg3< stop: func(arg2,arg3,stop) func(0,1,30) #斐波那契 武SIR def func(arg1,arg2): if arg1 == 0: print arg1, arg2 arg3 = arg1 + arg2 print arg3 func(arg2, arg3) func(0,1)
原文:http://www.cnblogs.com/weibiao/p/5245575.html