MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / listSum

Function listSum

Recursion.py:2–6  ·  view source on GitHub ↗
(numlist)

Source from the content-addressed store, hash-verified

1# 递归求和
2def listSum(numlist):
3 if len(numlist) == 1:
4 return numlist[0]
5 else:
6 return numlist[0] + listSum(numlist[1:])
7
8print(listSum([1, 2, 3, 4, 5, 6, 7]))
9

Callers 1

Recursion.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected