import java.io.*; import java.util.*; import java.math.*; public class NaiveExponentiation { public static void main(String [] args) { BigInteger a = new BigInteger(args[0]); int b = Integer.parseInt(args[1]); power(a,b); } public static void power(BigInteger base, int exponent) { BigInteger product = base; for(int i = 2; i <= exponent; i++) { product = product.multiply(base); } System.out.println("bitlength( " + base + " ^ " + exponent + " ) = " + product.bitLength()); System.out.println("numMultiplications = " + (exponent-1)); } }