python简单入门---代码复用和函数递归

代码复用和函数递归:

阶乘
def fact(n):
	if n==0 :
		return 1
	else :
		return n*fact(n-1)
		
def rvs(s):
	if s=='''
		return s
	else :
		return rvs(s[1:])+s[0]
	
	
count=0
def hanoi(n,src,dst,mid)
	globe count
	if n==1 :
		printf("{}:{}->{}''.format(1,src,dst))
		count+=1
	else
		hanoi(n-1,src,mid,dst)
		print("{}:{}->{}''.format(n,src,dst))
		count+=1
		hanoi(n-1,mid,dst,src)
	
		
	

你可能感兴趣的:(Python入门)