Ram is given a positive integer N .He wishes to convert this integer into a single numeral. He does so by repeatedly adding the numerals of the number until there is only a single numeral. Help Ram by providing the single-numeral number finally obtained.
def digSum(n):
if (n == 0):
return 0
if (n % 9 == 0):
return 9
else:
return (n % 9)
digSum(5463)
9
Comments
Leave a comment