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
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.
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.
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.
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.
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
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.
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.
War ruins the life and health of untold numbers of innocent children.
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..."