Saturday, January 18, 2003

 

Factoring numbers, Java program, word on ethical concerns

A while back I posted that I was staying away from research in factoring large numbers because I wasn't sure about the ethics of it. But someone else made a post about the ethics of finding some way to factor large numbers rapidly, and I read posts there and thought better of my position. Besides, there's no guarantee I can figure out away to factor numbers rapidly enough to endanger RSA, and even if I can, if I can figure it, so could someone else.

With all of the above said, it also occurs to me, yet again, that a breakthrough with factoring numbers would end the current logjam where my research on prime numbers and my proof of Fermat's Last Theorem are not gaining their proper recognition. Sure, reporters don't care about prime number researcch or some guy claiming to have proven FLT, but a fast factoring program will definitely get their attention.

With that said I'm including my latest Java program for factoring. It's in rough form as usual and doesn't necessarily give you a clean factorization, but I won't explain further because obviously, I'd just as soon not give out all details in case I figure out how to solve the RSA Challenge and get the prize money for myself. This program
clearly can't do the job, but at least it's better than what I last posted. James Harris

---------------------------------------------------------------------------

//Copyright James Harris All Rights Reserved 2003.
//Rough Java factoring program, still slow, but simple

import java.math.*;

public class Factor {


private BigInteger r,prevr, M;
private long n, rcalcs, loops, iterations;
private int count, next, next2;

private int[] nums =
{0,1,4,9,16,17,25,33,36,41,49,57,64,65,68,73,81,89,97,100,105,113,121,129,132,
137,144,145,153,161,164,169,177,185,193,196,201,209,217,225,228,233,241,249};


public void factor(BigInteger incoming){


next = (int)((incoming.toString()).length()/2);

r = (BigInteger.valueOf(10)).pow(next);

BigInteger res, diff, r1, r2, alpha=BigInteger.ONE;

//alpha = BigInteger.valueOf(1200000);

BigInteger temp1, temp2;

M = incoming.shiftLeft(2);

for (int i=0; i<100000; i++){

temp1 = M.multiply(alpha);

temp2 = (SqCalc(temp1).add(BigInteger.ONE)).pow(2);

diff = temp2.subtract(temp1);
if (checkLast(diff.intValue())) {

res = SqCalc(diff);

// System.out.println("result="+result);
// System.out.println("res="+res);

if (diff.subtract(res.pow(2))==BigInteger.ZERO) {

System.out.println("Number of iterations equals "+i);

System.out.println("beta="+diff);

temp2 = SqCalc(temp2);

r1 = res.add(temp2).shiftRight(1);
r2 = res.subtract(temp2).shiftRight(1);

System.out.println("alpha="+alpha);
System.out.println("r1 is "+ r1+"/"+alpha);
System.out.println("r2 is "+ r2+"/"+alpha);

return;
}
}
alpha = alpha.add(BigInteger.ONE);
}

System.out.println("Didn't find it.");
System.out.println("alpha="+alpha);

}

public static void main(String[] args) {

Factor myFactorer = new Factor();

try{

BigInteger incoming = new BigInteger(args[0]);

long time1 = System.currentTimeMillis();

myFactorer.factor(incoming);

System.out.println("In coming is "+incoming);

System.out.println("Processing time:
"+(System.currentTimeMillis()-time1));

System.out.println("Number of digits: "+args[0].length());
System.out.println("bitLength="+incoming.bitLength));

}
catch (Exception e){e.printStackTrace();}

}

private BigInteger SqCalc(BigInteger z){

for (count=0; count<256; count++){

loops++;

prevr = ((z.divide(r)).add(r)).shiftRight(1);

if (prevr.compareTo(r)==0){

return r;
}

r=prevr;

}

System.out.println("Exceeded count square root may be invalid.");
System.out.println("z="+z);
System.out.println("r="+r);

return r;

}

private boolean checkLast(int in){

next = in&0xF;

if (next==0||next==1||next==4||next==9){

next2 = in&0xFF;


for (count = 0; count<nums.length; count++){

if (nums[count]==next2) return true;

}

return false;

}
else{

return false;
}

}

}





<< Home

This page is powered by Blogger. Isn't yours?