Recursive Digit Sum

  • + 0 comments

    def superDigit(n, k): # Calculate the initial sum for the repeated number num = str(sum(map(int, str(n))) * k)

    # Define the helper function for finding the super digit
    while len(num) > 1:
        num = str(sum(map(int, num)))
    
    return int(num)