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))


Flowchart: Recursion: Sum of a non-negative integer.

No comments:

Post a Comment