Problem 146

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
axelbrz
Posts: 51
Joined: Mon Sep 08, 2008 5:34 am

Problem 146

Post by axelbrz »

Hi, I've used the problem forum to make a question about a solution.

Can anyone answer?

Thanks!! :)
"think(O(n))+O(n) sometimes is better than think(O(1))+O(1)"

Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 146

Post by hk »

Answered there.
Image
War ruins the life and health of untold numbers of innocent children.
axelbrz
Posts: 51
Joined: Mon Sep 08, 2008 5:34 am

Re: Problem 146

Post by axelbrz »

Thanks a lot!! :)
"think(O(n))+O(n) sometimes is better than think(O(1))+O(1)"

Image
michivo
Posts: 2
Joined: Mon Dec 08, 2008 4:20 pm

Problem 146

Post by michivo »

The description in Problem 146 says:
The smallest positive integer n for which the numbers n2+1, n2+3, n2+7, n2+9, n2+13, and n2+27 are consecutive primes is 10.

Why is 2 not a valid solution?
It is a positive integer
22+1 = 5 is prime
22+3 = 7 is prime
22+7 = 11 is prime
22+9 = 13 is prime
22+13 = 17 is prime
22+27 = 31 is prime
Still it says that 10 is the smallest positive integer for which these numbers are primes and 2 is not included in the provided solution for all integers below 1000000.
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Problem 146 - Error in description?

Post by stijn263 »

michivo wrote:The description in Problem 146 (View Problem) says:
The smallest positive integer n for which the numbers n2+1, n2+3, n2+7, n2+9, n2+13, and n2+27 are consecutive primes is 10.
You're missing 23 and 29
michivo
Posts: 2
Joined: Mon Dec 08, 2008 4:20 pm

Re: Problem 146 - Error in description?

Post by michivo »

stijn263 wrote:
michivo wrote:The description in Problem 146 (View Problem) says:
The smallest positive integer n for which the numbers n2+1, n2+3, n2+7, n2+9, n2+13, and n2+27 are consecutive primes is 10.
You're missing 23 and 29
Thanks - one word and I didn't see it the dozen times I went through the problem description.
User avatar
Georg
Posts: 157
Joined: Mon Jan 21, 2008 7:00 am
Location: Mannheim, Germany
Contact:

Re: Problem 146 - Error in description?

Post by Georg »

stijn263 wrote:
michivo wrote:The description in Problem 146 (View Problem) says:
The smallest positive integer n for which the numbers n2+1, n2+3, n2+7, n2+9, n2+13, and n2+27 are consecutive primes is 10.
You're missing 23 and 29
... and 19.
Smaug
Posts: 15
Joined: Thu Aug 06, 2009 5:08 pm

Re: Problem 146

Post by Smaug »

Can someone tell me the next highest n (above 10) please? I can't find any more!
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Problem 146

Post by stijn263 »

That n is between 10^5 and 5*10^5.

Good luck!
Smaug
Posts: 15
Joined: Thu Aug 06, 2009 5:08 pm

Re: Problem 146

Post by Smaug »

stijn263 wrote:That n is between 10^5 and 5*10^5.

Good luck!
Thanks - I will try to see why my code doesn't pick anything other than 10 up!
johnjohn
Posts: 1
Joined: Thu Dec 30, 2010 7:06 am

Re: Problem 146

Post by johnjohn »

hi,

I haven't really found a fast algorithm, I accomplished the first part though.

It takes me about 12 minutes to generate number 1242490...

------------------------
consecutive: 10
consecutive: 315410
consecutive: 927070
1242490

real 12m28.014s
user 12m21.386s
sys 0m5.176s
------------------------

//pseudocode >
// a bool function with one parameter X

// definition of a start variable which equals to (X*X+1), I don't use pow() because it seems to be slower
// then I define an end variable which equals to 'start + 26 '

// with these two variables I am able to do a loop. In the loop I check for 2 facts :
// 1. for every prime ( if count of all primes is higher than 6 primes, primes are no longer consecutive - function returns false )
// 2. for 1st, 3rd, 7th, 9th, 13th, 27th int if is prime - if not, returns false

I thought I implemented some proper speed hacks, but execution time doesn't really prove it. Having this execution time it's not a good idea to do a loop 150kk times.

I'd really appreciate any help you'd provide, thanks
rockstome
Posts: 17
Joined: Tue Sep 06, 2011 3:54 pm

Re: Problem 146

Post by rockstome »

below 10,000,000 sum is 11,914,460?
Thanks for reply
Image
JiminP
Posts: 14
Joined: Sun Nov 06, 2011 3:07 am
Location: Seoul, South Korea

Re: Problem 146

Post by JiminP »

rockstome wrote:below 10,000,000 sum is 11,914,460?
Probably. My result agrees with your result.

BTW, I wish that the limit 150m would be reduced to 90m. The integer (150m)^2 can't be represented in Javascript.. :(
Image
Eventhorizon
Posts: 19
Joined: Fri Sep 23, 2011 2:16 am

Re: Problem 146

Post by Eventhorizon »

Curious about this and similar problems:

Regarding the one-minute rule, do you generate the primes you need in your code and thus include the time to generate the primes in the one-minute, or do you use a pre-populated list of primes?

It takes my machine and R and what I think is a fairly good implementation of a sieve around 15s to generate a list of primes less than 150,000,000. Can anyone confirm that I need all those primes (except for the obvious ones) to solve this.

Let me know if this is not an appropriate question.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 146

Post by hk »

The numbers that must be consecutive primes are n^2+1, n^2+3, n^2+7, n^2+9, n^2+13, and n^2+27.
For n upto 150 000 000 this will be numbers as large as 22500000000000000. Precomputed primes (or even prime sieves) won't help you here. You need to do something to drastically reduce the numbers n you are considering.
Image
War ruins the life and health of untold numbers of innocent children.
Eventhorizon
Posts: 19
Joined: Fri Sep 23, 2011 2:16 am

Re: Problem 146

Post by Eventhorizon »

hk,

Thanks for your reply - only just saw it!
Image
User avatar
kenbrooker
Posts: 187
Joined: Mon Feb 19, 2018 3:05 am
Location: Northern California, USA

Re: Problem 146

Post by kenbrooker »

Greetings...

Posted a request for "help" at/with Problem 146 @ PE.net
If anyone might reply there or here, via
PM @ PE.chat...

Thanks in
Advance
"Good Judgment comes from Experience;
Experience comes from Bad Judgment
..."
Image
mdean
Posts: 206
Joined: Tue Aug 02, 2011 2:05 am

Re: Problem 146

Post by mdean »

kenbrooker wrote: Sat Mar 31, 2018 10:28 pm Greetings...

Posted a request for "help" at/with Problem 146 @ PE.net
If anyone might reply there or here, via
PM @ PE.chat...

Thanks in
Advance
Glasshopper, correct? My answer in the solution thread.
Image
User avatar
kenbrooker
Posts: 187
Joined: Mon Feb 19, 2018 3:05 am
Location: Northern California, USA

Re: Problem 146

Post by kenbrooker »

oops...
Forgot to mention my "name" and
it's a lowercase "g," please, but
Yes, You are correct and
I will look at PE.net
post haste...
Thanks!

EDIT:

I still haven't figured out how to bow out of a thread gracefully,
without triggering yet another red flag to everybody; but,
suffice it to say that traxex & mdean* & philiplu* have
answered my question easily (for them! : ) from
three different angles, adding up to 360d and
to each I say Thanks Again!!
*response @ PE.net

I am totally in awe and in appreciation of
the... Cerebral Capacity on tap within
Project Euler which, like "The Force,"
"surrounds us and permeates us and
binds The Galaxy"...

Now, about my question re
Problem 101...
"Good Judgment comes from Experience;
Experience comes from Bad Judgment
..."
Image
Post Reply