We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
static int superDigit(String n, int k) {
n = n.chars().mapToLong(Character::getNumericValue).sum() * k
+ "";
return (n.length() > 1) ? superDigit(n, 1) :
Character.getNumericValue(n.charAt(0));
}
Recursive Digit Sum
You are viewing a single comment's thread. Return to all comments →
Java 8 Solution (with Recursion)