Possible Duplicate:
diffucilty with BigInteger
import java.math.BigInteger;
public class KillerCode{
public static void main(String[]args){
BigInteger sum=null;
for(int i=1;i<=1000;i++){
sum=sum+Math.pow(i, i);
System.out.println(sum);
}
}
}
When I try to run this code the following error message is coming up.
The operator + is undefined for the argument type(s) BigInteger,double.
How can I solve this? Thank you.
You cannot use the typical math operators with BigIntegers, check here http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html
you need to use BigInteger.add(your numbers here)
Further Explination,
sum = sum.add(new BigInteger(i).pow(i));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With