Python solution using math


  • 0
    D
    import math
    class Solution:
        def addDigits(self, num):
            if num < 10:
                return num
            return int(num - 9*math.floor((num-1)/9))

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.