BigInteger number = new BigInteger("100"); BigInteger factorial = BigInteger.ONE; while (!number.equals(BigInteger.ZERO)) { factorial = factorial.multiply(number); number = number.subtract(BigInteger.ONE); } System.out.println("Factorial of 100 is: " + factorial);
BigInteger prime = BigInteger.probablePrime(256, new Random()); System.out.println("Random prime number of 256 bits is: " + prime);
BigInteger a = new BigInteger("123456789"); BigInteger b = new BigInteger("987654321"); BigInteger modulus = new BigInteger("1000000007"); BigInteger result = a.modPow(b, modulus); System.out.println("123456789^987654321 mod 1000000007 is: " + result);The package library for java.math.BigInteger is "java.math".