Python 五人分鱼
递归解法:
def need(n , r):
if n %5==1:
if r ==5:
returnTrue
else:
return need(n -(n -1)/5-1, r +1)
else:
returnFalse
n =6
whileTrue:
if need(n,1):
break
else:
n = n +5
print(n)
递归解法:
def need(n , r):
if n %5==1:
if r ==5:
returnTrue
else:
return need(n -(n -1)/5-1, r +1)
else:
returnFalse
n =6
whileTrue:
if need(n,1):
break
else:
n = n +5
print(n)