문제

   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.

도움이 되었습니까?

해결책

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())  {
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top