Java 코드에서 다음과 같은 "while"루프가 있습니다. 내 코드의 모든 변수는 BigIntegers입니다.무한 루프. Java BigInteger
BigInteger d=new BigInteger("1");
BigInteger e=new BigInteger("3");
BigInteger phi1=new BigInteger("6336");
while(true)
{
if(((d.multiply(e)).mod(phi1)).equals(BigInteger.ONE))
break;
d=d.add(BigInteger.ONE);
//System.out.println(d);
}
루프는이 경우 무한히 실행됩니다. 하지만 다음의 조건에 휴식을 추가 할 :
if((d*e)%phi1==1)
break;
나는 어디에서 잘못을 얻고있다
if(((d.multiply(e)).mod(phi1)).equals(BigInteger.ONE))
break;
로 BigInteger로 변환 한 어떤? 루프가 무한히 실행되는 이유는 누구나 알 수 있습니까?
숫자는 3입니다. 6 + 3 + 3 + 6 = 18 % 3이 0이므로 숫자는 3의 인수입니다. → 조건이 충족되지 않습니다. – Maroun
아니면 각 자릿수가 3의 배수인지 알 수 있습니다. : P 6336/3 = 2112 –