Page 1 of 2

Problem 196

Posted: Tue Jun 10, 2008 12:08 am
by petrw1
Does it have to be exactly a triple (no more, no less).
For example in row 6 is the number 17. It is part of a prime quad: 11. 13. 17. 23.
Or in row three the number 5 is part of a quad as well. 2, 3, 5, 7.

Therefore are these NOT to be considered a triple for purposes of this problem?

Re: Problem 196

Posted: Tue Jun 10, 2008 12:39 am
by JohnMorris
Being in a group greater than a triple counts as being in at least one triple.

In your example, both 5 and 17 would count as being in prime triples.

problem 196

Posted: Sun Jun 15, 2008 9:13 pm
by robheus
I have been trying to solve problem 196 (prime triplets) now for a couple of days.
The general algorithm I have, and it is correct for S(10000).
Generaring the numbers for S(5678027) gives me a result, as also S(7208785), but generating those numbers costs hours. The only performance improvement I made was caching intermediate results in a buffer. Perhaps pre-calculating all primes (for row -2 to row +2) in advance could improve the speed some more.

However when I check the result (adding the results for those two numbers) it turns out to be wrong.

I can't see something wrong with my algorithm though. Perhaps it overflows the integer type (long long unsigned int)?

Re: problem 196

Posted: Sun Jun 15, 2008 9:31 pm
by daniel.is.fischer
Your results were correct, the sum doesn't overflow even signed 64 bit integers. Try again, but be very sure that you don't have any whitespace in the textfield. If it doesn't work, contact me.

Re: problem 196

Posted: Sun Jun 15, 2008 9:55 pm
by robheus
daniel.is.fischer wrote:Your results were correct, the sum doesn't overflow even signed 64 bit integers. Try again, but be very sure that you don't have any whitespace in the textfield. If it doesn't work, contact me.
Thanks!
I found the error (it was in the last addition of those two results), and is now correct!

Re: problem 196

Posted: Sun Jun 15, 2008 9:57 pm
by daniel.is.fischer
I'm curious. How did you manage to get that wrong?

Re: Problem 196

Posted: Sun Jul 13, 2008 9:18 pm
by kvom
My program finds the solution for S(10000) quickly, and a solution for the other two lines not so quickly. Unfortunately their sum is not correct.

My program finds 27438 triplets in line 7208785. A hint as to whether this is high or low would help the debugging process. 8-)

Re: Problem 196

Posted: Sun Jul 13, 2008 11:40 pm
by Tommy137
Your number is far too large.

Re: Problem 196

Posted: Mon Jul 14, 2008 9:49 am
by Georg
Tommy137 wrote:Your number is far too large.
No, his number is too small.

Re: Problem 196

Posted: Mon Jul 14, 2008 10:16 am
by Tommy137
Georg wrote:
Tommy137 wrote:Your number is far too large.
No, his number is too small.
Mhm, I simply changed my code, so that it counts the primes that are a member of a triplet instead of computing the sum. The output was < 10000 :?

Maybe, he meant something else.

Re: Problem 196

Posted: Mon Jul 14, 2008 10:29 am
by ThomasH
Tommy137 wrote:178212 + 184112 = 192212
what about Fermat's last theorem?

Re: Problem 196

Posted: Mon Jul 14, 2008 11:28 am
by Georg
Tommy137 wrote:
Georg wrote:
Tommy137 wrote:Your number is far too large.
No, his number is too small.
Mhm, I simply changed my code, so that it counts the primes that are a member of a triplet instead of computing the sum. The output was < 10000 :?

Maybe, he meant something else.
Ooops. I did not change my program. I read that he computed S(10000) and compared it with the given value. So I did assume that his value was S(7208785) but it is not. I'm sorry, I did not count the triplets. My answer "No, his number is too small." is worthless.

Re: Problem 196

Posted: Mon Sep 01, 2008 7:39 pm
by sedefcho
S(200,000) = 8980000676761
S(200,001) = 4040040647250
S(200,002) = 3660072967149
S(500,005) = 134752693946582

Can someone confirm the correctness
or incorrectness of these results to me?

I am trying to find a bug in my code but I cannot see it yet.

I am able to get the answer for S(10,000) but
apparently I am still missing something.

Thanks in advance.

Re: Problem 196

Posted: Mon Sep 01, 2008 8:30 pm
by daniel.is.fischer
Those are correct.

Re: Problem 196

Posted: Tue Sep 02, 2008 4:01 pm
by sedefcho
Thanks for the reply.
I finally found my mistake.

Re: Problem 196

Posted: Wed Oct 14, 2009 5:50 pm
by Jochen_P
sedefcho wrote:Thanks for the reply.
I finally found my mistake.
Oh my god, I think I have the same mistake you had... Correct results for S(8), S(9), S(10000) <-14 ms., S(200,000-200,002) <- 64sec. and S(500,005) .
I thought fine, lets try it with the real numbers: Incorrect result !! :shock: :x :(

You know, it hurts a bit after 19.5 hours runtime :cry:

Guess my problem are triples at the very end of the row, anyone got a row to compare the results with ?

Re: Problem 196

Posted: Wed Oct 14, 2009 7:05 pm
by Jochen_P
Gawd!

used accidentally the wrong offset parameter to calculate with which didn't affect the sample results :roll:
Well, we'll see... I'll report back in 19.5 plus 4 hours (need my box for other things tonight ;) )

Re: Problem 196

Posted: Thu Oct 15, 2009 5:17 pm
by Jochen_P
just got the same (wrong) result with my corrected code... :(

Can anyone confirm the sum of [ S(1), S(2) ... S(10000) ] to be 5572672553494 ?

Re: Problem 196

Posted: Fri Oct 16, 2009 12:35 pm
by zwuupeape
My code can't handle that and it solves the original problem (now that I've optimized it a bit) in less than one minute. these are specific values for S:

S(100,000) = 549999566882
S(200,010) = 13741374650371
S(150,073) = 4549424035634

If your solution does not work for the values in the problem, but does for values high enough so as not to be causing problems with finding triplets, than probably your prime testing function cannot handle larger numbers or you get overflow at some point.

Re: Problem 196

Posted: Sun Oct 18, 2009 7:19 am
by Jochen_P
Got the same results as you have for S(100,000), S(200,010) and S(150,073) so I guess my triplet finding algorithm is ok. Well then, it must be a glitch in my (slow) prime finding solutions which hasn't shown yet for the other problems it has solved. Hard to find :?
My code can't handle that
You mean the sum of S(1) to S(10000)? Wonder how that can be..