Problem 008
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.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
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
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.
Problem 008
I get several errors when I try to post anything to the problem 8 topic.
So I can't show you my new whiz bang cool code
(Link to problem added by moderator: Problem 8 (View Problem))
So I can't show you my new whiz bang cool code
(Link to problem added by moderator: Problem 8 (View Problem))
Re: probem 8  can't post
I can confirm this.WyldOne wrote:I get several errors when I try to post anything to the problem 8 topic.
Re: probem 8  can't post
When I type n't there the code keeps inserting backslashes. (escape characters)
Problem seems resolved.
Problem seems resolved.
 euler
 Administrator
 Posts: 3258
 Joined: Sun Mar 05, 2006 4:49 pm
 Location: Cheshire, England
 Contact:
Re: probem 8  can't post
I've fixed both bugs, but I'm not certain why the main problem is happening. I switched to PHP5 last night and by switching back to the PHP4 seems to have fixed it. If anyone could explain why I would love to know. The posts were being entered into the database but it was writing the cached files that was causing the error: "fopen ... failed to open stream: Permission denied".
impudens simia et macrologus profundus fabulae
Re: probem 8  can't post
Is it possible someone clarify the problem 8 wording and definition, 'cause i think i have not understood it correctly.
What is the "greatest product of five consecutive digits" in this example: 29384293852611. I've tried to find 93852 and 9*3*8*5*2 and 9+3+8+5+2, but none of these work for accepted solution.
Thanks.
What is the "greatest product of five consecutive digits" in this example: 29384293852611. I've tried to find 93852 and 9*3*8*5*2 and 9+3+8+5+2, but none of these work for accepted solution.
Thanks.
Re: probem 8  can't post
The solution is the product of these 5 consecutive digits. If we call the digits a_{1} to a_{1000}, we search for the highest value of a_{n}*a_{n+1}*a_{n+2}*a_{n+3}*a_{n+4} (n=1,...,996) and this product has to be entered.
Re: probem 8  can't post
Tommy, you made sure, im on correct path. Then i rechecked code and found there was a char to integer conversion problem, that caused incorrect answers. Thanks.
Re: Problem 008
I would be interested in writing an official PDF answer to this question since the answers in the forum posts are not optimal. Rough overview follows but if you would consider letting me write the PDF I would write a pproper draft.
Basic explaination of increasingly better methods:
[snip]
Basic explaination of increasingly better methods:
[snip]
Re: Problem 008
I edited your message to remove text that could spoil it for folks who haven't solved it.
No one is working on an overview for problem 8, and you're welcome to do so. PM a team member to start the draft/review process.
No one is working on an overview for problem 8, and you're welcome to do so. PM a team member to start the draft/review process.

 Posts: 1
 Joined: Thu Nov 25, 2010 12:58 am
Re: Problem 008
I had a ton of trouble with this program because of the wording. I thought "consecutive" meant 1..2..3..4..5, 3..4..5..6..7, etc. so I wrote my program to solve it that way and I was wondering why it was only picking up strings where I inserted "12345". But then I reread it and I got it in 30 seconds

 Posts: 5
 Joined: Wed Feb 16, 2011 9:32 am
Re: Problem 008
99890 isn't the right answer,Why? What's the real mean of this problem?
Re: Problem 008
The problem asks for the product of the 5 digits.Darren_Zeng wrote:99890 isn't the right answer,Why? What's the real mean of this problem?
9*9*8*9*0 = 0
Zero is not very large, and certainly not the largest product you can get from 5 consecutive digits.
_{Jaap's Puzzle Page}

 Posts: 5
 Joined: Wed Feb 16, 2011 9:32 am
Re: Problem 008
I get the right answer.Thanks!jaap wrote:The problem asks for the product of the 5 digits.Darren_Zeng wrote:99890 isn't the right answer,Why? What's the real mean of this problem?
9*9*8*9*0 = 0
Zero is not very large, and certainly not the largest product you can get from 5 consecutive digits.
Re: Problem 008
I'd like a wording change for this one too.
In addition to the abovementioned 1234567... interpretation of "consecutive digits" and the possible slight misinterpretation of "product" (though... on a math problem site...), the way I first tried to solve this was still using a "product of five consecutive digits", but it gave me a larger answer.
I didn't just test for v*w*x*y*z, but also (10*v+w)*x*y*z, etc. So not just 1*2*3*4*5, but also 12*3*4*5, 123*45, 1234*5, etc. Considering the wording, that should still qualify, but it doesn't. I had to check the forum to see what the problem actually intended.
And even in my notes before writing the program, I also made a comment to myself of another possible interpretation where the consecutive digits from the 1000digit number, once pulled out, might be rearranged  add that to my original misinterpretation above and the possible answer would be even further off.
In any case, thanks for the site! It's been a very nice way to check my programming chops and have many multilingual (and often more efficient/elegant) examples to compare to after solving.
In addition to the abovementioned 1234567... interpretation of "consecutive digits" and the possible slight misinterpretation of "product" (though... on a math problem site...), the way I first tried to solve this was still using a "product of five consecutive digits", but it gave me a larger answer.
I didn't just test for v*w*x*y*z, but also (10*v+w)*x*y*z, etc. So not just 1*2*3*4*5, but also 12*3*4*5, 123*45, 1234*5, etc. Considering the wording, that should still qualify, but it doesn't. I had to check the forum to see what the problem actually intended.
And even in my notes before writing the program, I also made a comment to myself of another possible interpretation where the consecutive digits from the 1000digit number, once pulled out, might be rearranged  add that to my original misinterpretation above and the possible answer would be even further off.
In any case, thanks for the site! It's been a very nice way to check my programming chops and have many multilingual (and often more efficient/elegant) examples to compare to after solving.
Re: Problem 008
If you'd searched Wikipedia on "digit" you would have found http://en.wikipedia.org/wiki/Digit.
The second link on that page would have brought you to this page http://en.wikipedia.org/wiki/Numerical_digit eliminating almost all of your misconceptions.
The second link on that page would have brought you to this page http://en.wikipedia.org/wiki/Numerical_digit eliminating almost all of your misconceptions.

 Posts: 1
 Joined: Sun Jun 05, 2011 8:23 am
Re: Problem 008
Wow, I am glad I checked this forum. I misunderstood this problem in an almost hilariously incorrect way.
The problem reads:
Find: (the greatest product of five consecutive digits) in: (the 1000digit number)
So I was looking for the numbers 1*2*3*4*5, 2*3*4*5*6, 3*4*5*6*7, as subsequences of the 1000digit number. By the way, the product 2*3*4*5*6 is 720 and appears at position 388
Is consecutive the right word here? I always thought consecutive implied ordered; 1,2,3,4,5 are consecutive; 5,6,0,1,3 are not although they appear adjacent to each other in the 1000digit number.
Going straight to MerriamWebster:
The problem reads:
I dissected the sentence thusly:Find the greatest product of five consecutive digits in the 1000digit number...
Find: (the greatest product of five consecutive digits) in: (the 1000digit number)
So I was looking for the numbers 1*2*3*4*5, 2*3*4*5*6, 3*4*5*6*7, as subsequences of the 1000digit number. By the way, the product 2*3*4*5*6 is 720 and appears at position 388
Is consecutive the right word here? I always thought consecutive implied ordered; 1,2,3,4,5 are consecutive; 5,6,0,1,3 are not although they appear adjacent to each other in the 1000digit number.
Going straight to MerriamWebster:
Anyway, if mathematicians routinely use the word "consecutive" to describe any elements that appear next to each other in a list, then I'll crawl back into my hole.Definition of CONSECUTIVE
: following one after the other in order : successive
Re: Problem 008
Consecutive is referring to the positions of the digits; not the values of the digits. The 2nd, 3rd, 4th, 5th, and 6th digits in the number are consecutive digits in the number.
It is true that you could consider the digits 1, 2, 3, 4 and 5 to be consecutive digits, but I don't think that really makes as much sense with this wording. (You could also say that 5, 6, 7, 8 and 9 are consecutive digits, and they each appear in the 1000 digit number, but that's getting a bit silly )
It is true that you could consider the digits 1, 2, 3, 4 and 5 to be consecutive digits, but I don't think that really makes as much sense with this wording. (You could also say that 5, 6, 7, 8 and 9 are consecutive digits, and they each appear in the 1000 digit number, but that's getting a bit silly )

 Posts: 1
 Joined: Sat Aug 20, 2011 8:03 pm
Re: Problem 008
Oh, boy. Complete reading comprehension failure on my part.
I read the problem originally as "greatest product of five consecutive NUMBERS" and took half a day coming up with a brute force solution. Go through all possible substrings, filter for those whose last three digits aren't divisible by 8, filter for those which don't sum to a multiple of 3, then for those remaining, do a brute force binary search. Turns out, in that case, the answer is 720.
Then I visited this forum, reread the problem, and discovered I need to go back to gradeschool to improve my english.
At least coming up with the brute force search method was fun. And ran quicker than I expected.
I was wondering why such a difficult problem popped up so early.
I read the problem originally as "greatest product of five consecutive NUMBERS" and took half a day coming up with a brute force solution. Go through all possible substrings, filter for those whose last three digits aren't divisible by 8, filter for those which don't sum to a multiple of 3, then for those remaining, do a brute force binary search. Turns out, in that case, the answer is 720.
Then I visited this forum, reread the problem, and discovered I need to go back to gradeschool to improve my english.
At least coming up with the brute force search method was fun. And ran quicker than I expected.
I was wondering why such a difficult problem popped up so early.
Re: Problem 008
I'm having trouble getting started at all here. I know that I'll be looking at a_{n}*a_{n+1}*a_{n+2}*a_{n+3}*a_{n+4} when it comes to the digits but as far as expressing the digits, I'm lost. I was thinking of using the string class and elements in the string but I can't seem to do that. I don't want the answer to the puzzle but can someone help me store and display such a long number?
Re: Problem 008
You didn't say what language you're working with. Some, like C and Java, treat characters and integers somewhat interchangeably. And in ASCII, the digits are sequentially valued, so you can subtract the constant '0' to get the value. I have used statements like:vulcant wrote:I'm having trouble getting started at all here. I know that I'll be looking at a_{n}*a_{n+1}*a_{n+2}*a_{n+3}*a_{n+4} when it comes to the digits but as far as expressing the digits, I'm lost. I was thinking of using the string class and elements in the string but I can't seem to do that. I don't want the answer to the puzzle but can someone help me store and display such a long number?
digitValue = digitArray  '0';
to get the numeric value of an individual digit.