COMPUTER SCIENCE PYTHON AND C++
Monday, June 29, 2020
Python Recursive Program for Digit Addition of Integer's
def
sumDigits
(
n
)
:
if
n
==
0
:
return
0
else
:
return
n
%
10
+
sumDigits
(
int
(
n
/
10
)
)
print
(
sumDigits
(
345
)
)
print
(
sumDigits
(
45
)
)
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment