just i trying to implements the NF(New Factorization) method published on the paper
Example 4:
Let N=21
S=5
P=gcd(24,21)=3>1
Q=21/3=7
P and Q is factor of N.
NF method as follows:
1. Let any positive integer is N.
2. Compute the square root of N.
3. Take ceiling function of step two.
4. Decrement by one in square of step three.
5. Compute the greatest Common divisor of step three and step number one.
6. If step five is grater than one.
7. Step five is a factor of step one.
8. Compute other factor of N divided by step seven.
9. Otherwise increment the value of steps three by one and continues step three to eight, till step four is grater than one.
but i not understand how i can get the "24" ?
long n = 21;
long s = (long) (Math.ceil(Math.sqrt(n)));
long p = gcd(24, n);
if(p>1){
long q = n/p;
boolean success = (q*p==n);
if(success) System.out.println("P: " + p + " Q: " + q);
}
Solution
long n = 21;//999962000357L
long s = (long) (Math.ceil(Math.sqrt(n)));
long p;
long b;
while(true){
b = s*s-1;
p = gcd(n, b);
s = s+1;
if(p != 1) break;
}
if(p>1){
long q = n/p;
boolean success = (q*p==n);
if(success) System.out.println("P: " + p + " Q: " + q);
}
It seems that the following pseudo code is intended:
This does not look like a serious method though: The gcd simply tests against common factors with $s+1$ and $s-1$; hence an immediate improvement consists in simply testing the $\gcd$ of $N$ with all the integers from $\lfloor\sqrt N\rfloor$ onward ...