as you can tell by the title, I am working on trying to brute force the factorization of large integers whose factors are 2 primes. I was wondering if there was a way to use a for loop inside a for loop for this. I know this is a TERRIBLE way to do it but i would like to do it anyways. ( I was going to use fermats factorization theorem but u cant sqrt BigIntegers without some extra method / library and I cannot do that) So just try and see if you can help me with what I am doing. Someting along the lines of this:
BigInteger n = new BigInteger("270653957405596110781"); // this is what i need the factors of
BigInteger TWO = new BigInteger("2");
for( BigInteger i = new BigInteger("1"); i < n.divide(TWO); i.nextProbablePrime() ){
for( BigInteger k = new BigInteger("1"); k < n.divide(TWO); k.nextPossiblePrime){
if(i.Multiply(k) = n){
//i and k are the factors, and return them
}
}
}
obviously thats atrocious and i know that you cannot just increase to the next prime by saying i.nextPossiblePrime(), you would need it to say i = i.nextpossible prime, I was just showing you of kind of how i wanted it to work; but thats why I am asking because idk if something like this is even possible!
Please let me know if this route is possible and how i could fix this bad code to function like i am visualizing it!
Thanks!