You are viewing a single comment's thread. Return to all comments →
def superDigit(n, k): str1 = str(n) sum1 = 0 for char in str1: sum1 += int(char) sum1 = k*sum1 while True: str2 = str(sum1) sum1 = 0 for char in str2: sum1 += int(char) if sum1 < 10: break return sum1
Seems like cookies are disabled on this browser, please enable them to open this website
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
def superDigit(n, k): str1 = str(n) sum1 = 0 for char in str1: sum1 += int(char) sum1 = k*sum1 while True: str2 = str(sum1) sum1 = 0 for char in str2: sum1 += int(char) if sum1 < 10: break return sum1