You are viewing a single comment's thread. Return to all comments →
public static int superDigit(String n, int k) { if(n.length()==1){ return Integer.parseInt(n); } long sum=0; char[] ch=n.toCharArray(); for(int i=0;i<ch.length;i++){ sum+=Character.getNumericValue(ch[i]); } sum=sum*k; return superDigit(String.valueOf(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 →
java