Hi,
I am trying to use the pow() method from the math library. I searched this forum for some help and this what I found on how to use it:
BigInteger bi = new BigInteger(x);
int result = bi.pow(y);
I taught when using this constructor x is a
string, y has to be an integer. How can I use BigIntegers and integers with the pow() method?
What I tried to do is something like this:
BigInteger numGrains = new BigInteger("1");
int result = numGrains.pow(numGrains);
System.out.print(" " + result + " ");
This is the error message I recive when try to compile the class:
"pow(int) in java.math.BigInteger cannot be applied to (java.math
.BigInteger)int result = numGrains.pow(numGrains)"
I understand I'm passing the wrong argument type and when try to pass an integer I get this message:
incompatible types found : java.math.BigInteger
required: int
int result = numGrains.pow(2);
^
Is this not an int? I double checked it in
Java API how to pass argument and cannot see the problem. I am confused.
Any help would be great!
Thanks,
moni