library for integer factorization in java or scala

Viewed 1921

There are a lot of questions about how to implement factorization, however for production use, I would rather use an open source library to get something efficient and well tested right away. The method I am looking for looks like this:

static int[] getPrimeFactors(int n)

it would return {2,2,3} for n=12

A library may also have an overload for handling long or even BigInteger types

The question is not about a particular application, it is about having a library which handles well this problem. Many people argue that different implementations are needed depending on the range of the numbers, in this regard, I would expect that the library select the most reasonable method at runtime.

By efficient I don't mean "world fastest" (I would not work on the JVM for that...), I just mean dealing with int and long range within a second rather than a hour.

4 Answers
Related