How to increase performance of Java\'s Big Integer?
For example, this factorial program:
import java.math.*;
class Fac {
public static void main(String
Other answers are related to tune the performance using code.
If you are using java version less than 1.8.0_151, you can tune big integer performance by using the following command options:
-XX:+UseMontgomerySquareIntrinsic
-XX:+UseMontgomeryMultiplyIntrinsic
-XX:+UseSquareToLenIntrinsic
-XX:+UseMultiplyToLenIntrinsic
After 1.8.0_151, these options are turned on by default.