You are viewing a single comment's thread. Return to all comments →
Test cases are ridiculously big. Had to modify it 3 times. Here is mine in C#
public static int superDigit(string n, int k) { long result = 0; foreach(char c in n) result += int.Parse(c.ToString()); result *= k; return Convert.ToInt32(superDigit(result.ToString())); } public static int superDigit(string n) { int result = 0; foreach (char c in n) result += int.Parse(c.ToString()); n = result.ToString(); if (int.Parse(n) <= 10) return int.Parse(n); return superDigit(n); }
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 →
Test cases are ridiculously big. Had to modify it 3 times. Here is mine in C#