You are viewing a single comment's thread. Return to all comments →
I dont know what im doing wrong:
public static int superDigit(String n, int k) { StringBuilder superNBuilder = new StringBuilder(n); for(int i=0;i<k-1;i++) { superNBuilder.append(n); } String superN = superNBuilder.toString(); BigInteger result = new BigInteger(""+superN.charAt(0)); while(superN.length()>1){ result=BigInteger.ZERO; for(int i=0;i<superN.length();i++){ result=result.add(new BigInteger(""+superN.charAt(i))); } superN=result.toString(); } return result.intValue(); }
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:
I dont know what im doing wrong: