You are viewing a single comment's thread. Return to all comments →
Here is my solution to this problem in Java
public static int superDigit(String n, int k) { if(n.length() == 1){ return Integer.parseInt(n); } long sum = n.chars().mapToLong(x -> Integer.parseInt(Character.toString(x))).sum() * k; return superDigit(Long.toString(sum), 1); }
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 →
Here is my solution to this problem in Java