Write a function program to add the digits of a positive integer repeatedly until the result has a single digit.
Topic: Write a function program to add the digits of a positive integer repeatedly until the result has a single digit.
Solution
def add_digits(num): return (num - 1) % 9 + 1 if num > 0 else 0
List all Python Programs