You are viewing a single comment's thread. Return to all comments →
public static int superDigit(String n, int k) { return superDigitRecurs((superDigitRecurs(n) * k) + ""); } private static int superDigitRecurs(String s){ if (s.length() == 1) return Integer.parseInt(s); int total = 0; for (char c : s.toCharArray()) total += Integer.parseInt(c + ""); return superDigitRecurs(total + ""); }
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 →
Java recursive