Recursive Digit Sum

  • + 2 comments

    Python3

    def superDigit(n, k):
        # Write your code here
        res = sum(int(i) for i in str(n)) * k
        while res > 10:
            res = sum(int(i) for i in str(res))
        return res