MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / sum

Function sum

Python/5 recusrion problems.py:48–53  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

46# 4..TO FIND THE SUM OF ALL DIGITS IN THE GIVEN NUMBER
47
48def sum(n):
49 assert n>=0 and int(n)==n , "only positive integers"
50 if n==0:
51 return 0
52 else:
53 return int(n%10) + sum(int(n//10))
54
55print(sum(11))
56

Callers 3

dpFunction · 0.85
max_circular_subarrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected