You are viewing a single comment's thread. Return to all comments →
c#
public static int superDigit(string n, int k) { long start = 0; for(int i = 0; i < n.Length; i++) { start += (n[i] - '0'); } start = start * k; return (int)backtrack(start); } static long backtrack(long num) { if(num <= 9) return num; long res = 0; while(num > 0) { res += num % 10; num = num / 10; } return backtrack(res); }
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 →
c#