Mersenne Primes - I have this program that I missed points on because they said a Mersenne prime must also be a prime itself. What do I need to add? I've included the original assignment below:
import java.util.*;
import java.math.BigDecimal;
import java.math.BigInteger;
public class MersennePrimes {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter max p: ");
long number = sc.nextLong();
for (int i = 2; i <= number; i++) {
BigInteger b = new BigInteger(String.valueOf(i));
if (b.isProbablePrime(1)) {
BigInteger k = BigDecimal.valueOf(Math.pow(2, i) - 1).toBigInteger();
System.out.println(i + " " + k);
}
}
}
}