Problem getting biginteger to work

I want to do this with bigintegers note that MaxNum is a big integer and x is just a regular integer.

I tried writing Code:

`if(MaxNum.mod(x) == 0)`

but the compiler tells me to convert x to a big integer which I rather avoid if possible.

Re: Problem getting biginteger to work

All calculation methods in BigInteger class require you to use BigInteger as the parameter. These methods like add(), mod(), multiply(), divide(), etc. There's no overload that I can see that accept integer. So you have to convert it. You can do by using BigInteger.valueOf(x).

Re: Problem getting biginteger to work

Quote:

Originally Posted by

**wsaryada** All calculation methods in BigInteger class require you to use BigInteger as the parameter. These methods like add(), mod(), multiply(), divide(), etc. There's no overload that I can see that accept integer. So you have to convert it. You can do by using BigInteger.valueOf(x).

Do you mean for it to be like this?

Code:

`if(MaxNum.mod(BigInteger.valueOf(x)) == Zero)`

Where "Zero" is: Code:

` BigInteger Zero= new BigInteger ("0");`

For some reason this just freezes my program. I get no error.

Re: Problem getting biginteger to work

Do this instead:

Code:

`if(MaxNum.mod(BigInteger.valueOf(x)).equals(BigInteger.ZERO))`

kind regards,

Jos