We define a merge prime as a prime number that can be split into two prime numbers.
Some examples of merge primes are:
What are the last three digits of the sum of all 7-digit merge primes?
Clarification
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Generate all prime numbers up to 6-digit. Concatenate those that will form a 7-digit number and check if they are prime. So we can split the number into morethan two primes? Let's say is 9998903 a merge prime?
Log in to reply
No, we can only split them into exactly two primes. What I meant is to concatenate 6-digit prime with 1-digit prime, 5-digit prime with 2-digit prime, etc.
Log in to reply
is 9998903 a merge prime?
Log in to reply
@Join Turva – Yes. But my program missed that. Might need to fix the problem.
Log in to reply
@Christopher Boo – Which sum do you mean? Let's say, I have a set of number [1,2,3,4,5], sum=5, this sum or ,sum=15, this sum?
@Join Turva – It's ambigous cause I think 9998903 is a prime but not a merge prime,we can split into 999890 and 3 which mean it's not a merge prime but based on your solution 9998903 can be splited into 99989 and 3 but it will be 6-digit merge prime not 7-digit merge prime
Log in to reply
@Join Turva – Yes you are correct. I do agree that 9 9 9 8 9 0 3 is a merge prime but my solution missed that out. I will update the solution accordingly. What did you got?
bro, change the problem description please, you include the 9998903 as merge prime
Log in to reply
9 9 9 8 9 0 3 is a merge prime.
Log in to reply
add an asumption in your problem then
Log in to reply
@Join Turva – I've edited the problem, is it clear now?
Log in to reply
@Christopher Boo – okay by the way you said that you took 2 and half minute with your algorithm, mine only 5 sec
Log in to reply
@Join Turva – I'm impressed, what's your solution?
Log in to reply
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
@Christopher Boo – I simply using sieve and little bit modification in my solution
Isn't 1000032 a 7 digit merge prime? But in your answer you didn't count that as 7 digit merge prime. Can you explain why?
Here's the more naive solution of testing all 7-digit numbers for primality.
Takes about 9 seconds to run. I first started writing it in Python, but I was too impatient for it to finish running. It might be fast using NumPy, but I haven't tried.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
|
(Time: 23.5 s)
Problem Loading...
Note Loading...
Set Loading...
I have two approach :
I tried the latter one and below is the code. It took me two and a half minute, I wonder what is the runtime of the first approach?
The output is 7 1 4 9 4 0 4 6 8 3 9 9 .
I didn't include my
isPrime(x)
function to make the code clearer. You can replace it with any prime testing algorithm you feel comfortable with. Of course, the optimal one will be Miller-Rabin algorithm