Class Lehman_Fast
- java.lang.Object
-
- de.tilman_neumann.jml.factor.FactorAlgorithm
-
- de.tilman_neumann.jml.factor.lehman.Lehman_Fast
-
public class Lehman_Fast extends FactorAlgorithm
Fast implementation of Lehman's factor algorithm. Works flawlessly for N up to 60 bit.
It is quite surprising that the exact sqrt test oftest = a^2 - 4kN
works for N >= 45 bit. At that size, both a^2 and 4kN start to overflow Long.MAX_VALUE. But the error - comparing correct results vs. long results - is just the same for both a^2 and 4kN (and a multiple of 2^64). Thustest
is correct andb
is correct, too.a
is correct anyway. Lehman_CustomKOrder is considerably faster for any kind of test numbers. This class is kept for reference as it was implemented by bSquare, see https://www.mersenneforum.org/showpost.php?p=506294&postcount=7
-
-
Field Summary
-
Fields inherited from class de.tilman_neumann.jml.factor.FactorAlgorithm
DEFAULT, NUM_PRIMES_FOR_31_BIT_TDIV, tdivLimit
-
-
Constructor Summary
Constructors Constructor Description Lehman_Fast(boolean doTDivFirst)
Full constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
findSingleFactor(long N)
BigInteger
findSingleFactor(BigInteger N)
Find a single factor of the given N, which is composite and odd.String
getName()
static void
main(String[] args)
Test.-
Methods inherited from class de.tilman_neumann.jml.factor.FactorAlgorithm
factor, factor, searchFactors
-
-
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getName
in classFactorAlgorithm
- Returns:
- The name of the algorithm, possibly including important parameters.
-
findSingleFactor
public BigInteger findSingleFactor(BigInteger N)
Description copied from class:FactorAlgorithm
Find a single factor of the given N, which is composite and odd.- Specified by:
findSingleFactor
in classFactorAlgorithm
- Returns:
- factor
-
findSingleFactor
public long findSingleFactor(long N)
-
main
public static void main(String[] args)
Test.- Parameters:
args
- ignored
-
-