Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Mat
- */
- package problem.pkg10;
- import java.math.BigInteger;
- public class Problem10 {
- public static void main(String[] args) {
- BigInteger total = new BigInteger("2");
- final int TWO_MILLION = 2000000;
- for(BigInteger i = new BigInteger("3");
- i.compareTo(BigInteger.valueOf(TWO_MILLION)) < 0;
- i = i.add(BigInteger.valueOf(2))){
- //Testing if prime if so add it to total
- if(i.isProbablePrime(10)){
- total = total.add(i);
- }
- }
- System.out.println("The total is: " + total.toString());
- }
- }
- /* Output
- * The total is: 142913828922
- */
Advertisement
Add Comment
Please, Sign In to add comment