Computer Science, asked by aisabhi7770, 9 hours ago

Powerful NumberTouka is fan of big numbers, so when her friend kuroko gives her a positive number N she calculates M=2Npower N) and tell it to him .But since M can be very large so it is very difficult for her to tell it to kuroko. So shecalculate the sum of digits of M till she gets a single digit number and tells it to kuroko.Touka is very tired of the calculation and needs your help to calculate it for her.Her friend kuroko asks her T queries.In each query you will be given N as inputPrint the answer reqired in each query.ExampleLet's assume that N=6 then M = 26 = 64.​

Answers

Answered by nitin2424
19

Answer:

beginner 493929229921919

Answered by artificialgeniusashy
25

Answer:

static int power(int N, int P) {

 if (P == 0)

  return 1;

 else

  return N * power(N, P - 1);

}

private static boolean isMultiDigitString(String a) {

 if (a.length() > 1) {

  return true;

 }

 return false;

}

private static void solve() {

 int n = 10;

 System.out.println(power(2, n));

 int M = power(2, n);

 String mString = new String("" + M);

 System.out.println(mString);

 Integer b = new Integer(mString);

 System.out.println("b ="+b);

 while (isMultiDigitString(b.toString())) {

  Integer tmp = new Integer(0);

  for (int i = 0; i < b.toString().length(); i++) {

   tmp += Integer.parseInt((String.valueOf(b.toString().charAt(i))));

   System.out.println(mString.charAt(i) + "...." + "i =" + b);

  }

  b = tmp;

  System.out.println(b);

 }

}

public static void main(String[] arg) {

 solve();

}

Explanation:

Similar questions