Question

   switch (n.mod(BigInteger.valueOf(8)))  {
    case 1:
    case 7:
        jacobi = BigInteger.valueOf(1);
        break;
    case 3:
    case 5:
       jacobi = BigInteger.valueOf(-1);
        break;}

I get "BigInt can't be converted to int". Switch also wants constant expressions, so I can't put BigInteger.valueOf(1), neither.

Was it helpful?

Solution

The mod method returns another BigInteger, and a BigInteger is a Number, so you can just call intValue() to get an int that can be the switch argument.

switch (n.mod(BigInteger.valueOf(8)).intValue())  {
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top