## Problem:

The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four primes with this property.

Find the lowest sum for a set of five primes for which any two primes concatenate to produce another prime.

142913828922

## Code:The solution may include methods that will be found here: Library.java .

public interface EulerSolution{public String run();}
/*  * Solution to Project Euler problem 10 * By Nayuki Minase *  * http://nayuki.eigenstate.org/page/project-euler-solutions * https://github.com/nayuki/Project-Euler-solutions */public final class p010 implements EulerSolution {		public static void main(String[] args) {		System.out.println(new p010().run());	}			private static final int LIMIT = 2000000;		public String run() {		long sum = 0;		for (int p : Library.listPrimes(LIMIT - 1))			sum += p;		return Long.toString(sum);	}	}

## Follow Me

If you like our content, feel free to follow me to stay updated.

## Subscribe

Enter your email address:

We hate spam as much as you do.

## Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?
Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact