Problem 002
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.
-
newinkles
- Posts: 1
- Joined: Sun Mar 02, 2008 8:57 pm
Problem 002
In the problem it says the sum of the even valued terms that do not exceed 4million. But the answer is the first term over 4 million. This might need to be reworded.
Nathan
Nathan
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 2
Why should the sum of the even valued fibonacci numbers less than 4 million not exceed 4 million?
The first fibonacci number that exceeds four million is 5702887. And that's not the correct answer.
So the individual terms to add must be less than 4 million, the sum does not need to be.
The first fibonacci number that exceeds four million is 5702887. And that's not the correct answer.
So the individual terms to add must be less than 4 million, the sum does not need to be.

War ruins the life and health of untold numbers of innocent children.
- kinyel
- Posts: 4
- Joined: Thu Apr 10, 2008 7:05 pm
problem 2 help please translate or example ...
Hello
I'm french (nobody's perfect...
) and my english is bad ...
and I don't understand really
"Find the sum of all the even-valued terms in the sequence which do not exceed four million."
what is "even valued" ? why not only "all terms" ?
please can someone translate in french, or (better ?) give me the wanted sum for the first 10 terms for example ...
( 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 )
I can't solve this problem even if I've solve 20 others problems yet

thanks for help !
I'm french (nobody's perfect...
and I don't understand really
"Find the sum of all the even-valued terms in the sequence which do not exceed four million."
what is "even valued" ? why not only "all terms" ?
please can someone translate in french, or (better ?) give me the wanted sum for the first 10 terms for example ...
( 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 )
I can't solve this problem even if I've solve 20 others problems yet
thanks for help !
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: problem 2 help please translate or example ...
even numbers are numbers divisible by 2.
So you are asked to sum the Fibonacci numbers less than 4 million that are divisible by 2.
So you are asked to sum the Fibonacci numbers less than 4 million that are divisible by 2.

War ruins the life and health of untold numbers of innocent children.
- kinyel
- Posts: 4
- Joined: Thu Apr 10, 2008 7:05 pm
Re: problem 2 help please translate or example ...
thank you very, very much !
(never I think this and automatic translate don't give this ...)
(never I think this and automatic translate don't give this ...)
-
dgiancaspro
- Posts: 2
- Joined: Sat Oct 25, 2008 10:58 pm
Problem 2 -- What the heck ?
Sorry in advance for the long post ....
I completely understand the problem as it is stated. I wrote a quick brute force ruby program ... here it is ...
[snip]
I can't see what I'm doing wrong ... a nudge ... or a brick to the head ... in the right direction would be appreciated.
Thanks
Dave
I completely understand the problem as it is stated. I wrote a quick brute force ruby program ... here it is ...
[snip]
I can't see what I'm doing wrong ... a nudge ... or a brick to the head ... in the right direction would be appreciated.
Thanks
Dave
Last edited by daniel.is.fischer on Sat Oct 25, 2008 11:24 pm, edited 1 time in total.
Reason: Remove code and answer
Reason: Remove code and answer
- xan
- Posts: 621
- Joined: Sat Jul 28, 2007 12:43 am
- Location: North Carolina, USA
- Contact:
Re: Problem 2 -- What the heck ?
I can verify that your answer is correct. Please edit your post to remove the answer and code to avoid spoiling it for anyone else.
I don't know why your answer wasn't accepted. Maybe a copy/paste brought in some extra characters. If the problem persists, maybe an admin can figure out what the problem is.
I don't know why your answer wasn't accepted. Maybe a copy/paste brought in some extra characters. If the problem persists, maybe an admin can figure out what the problem is.
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: Problem 2 -- What the heck ?
Whether it was a copy/paste slip or a server glitch, please try again and if that doesn't work, notify us.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
dgiancaspro
- Posts: 2
- Joined: Sat Oct 25, 2008 10:58 pm
Re: Problem 2 -- What the heck ?
Looks like it was a Copy/Paste glitch ... The one thing I didn't try was typing it in by hand. That's what I get for being lazy.
Sorry for the spoiler .... I'll remember that in the future ...
Thanks
Dave
Sorry for the spoiler .... I'll remember that in the future ...
Thanks
Dave
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 2
Snipped out possible spoilers.
I don't think that makes for an efficient method: floats are slow compared to integers, moreover simple adding is much faster than multiplying or taking powers.
My prog based on the pdf runs in 0.003 milliseconds on a more than 4 years old computer using Delphi. (25 times as fast as yours)
Please do not post things like this again in the public part of this forum.
I don't think that makes for an efficient method: floats are slow compared to integers, moreover simple adding is much faster than multiplying or taking powers.
My prog based on the pdf runs in 0.003 milliseconds on a more than 4 years old computer using Delphi. (25 times as fast as yours)
Please do not post things like this again in the public part of this forum.

War ruins the life and health of untold numbers of innocent children.
-
chinesefishmarket
- Posts: 4
- Joined: Fri Nov 28, 2008 7:43 pm
Re: Problem 2
I'm having trouble with getting an answer for #2.
I have tried it for smaller numbers (limit 55) and I get 44 (34 + 8 + 2) for the answer. When I enter 4000000 as my limit, I get the wrong answer. Is there something I am missing about this problem?
I have tried it for smaller numbers (limit 55) and I get 44 (34 + 8 + 2) for the answer. When I enter 4000000 as my limit, I get the wrong answer. Is there something I am missing about this problem?
- ed_r
- Posts: 1009
- Joined: Sun Jul 29, 2007 10:57 am
Re: Problem 2
Probably. Keep plugging away at it; you'll get there in the end. Good luck 
(please note: this is not a hints forum!)
(please note: this is not a hints forum!)
!647 = &8FDF4C
-
chinesefishmarket
- Posts: 4
- Joined: Fri Nov 28, 2008 7:43 pm
Re: Problem 2
But if it works for a smaller number, it should work for a larger number as well.
I think the problem is my answers are coming out to be in the format X.XXXe+00X, because I tried problem 6 and it also said it was wrong.
So if my answer is 1.111e+003, the correct answer should be 1111 right?
(^ not an answer I got for either problem, just the same format).
I think the problem is my answers are coming out to be in the format X.XXXe+00X, because I tried problem 6 and it also said it was wrong.
So if my answer is 1.111e+003, the correct answer should be 1111 right?
(^ not an answer I got for either problem, just the same format).
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
-
chinesefishmarket
- Posts: 4
- Joined: Fri Nov 28, 2008 7:43 pm
Re: Problem 2
C++stijn263 wrote:try using integers instead of floats/doubles.
what programming language do you use?
-
chinesefishmarket
- Posts: 4
- Joined: Fri Nov 28, 2008 7:43 pm
Re: Problem 2
OK. Forcing everything to be int works out great.chinesefishmarket wrote:C++stijn263 wrote:try using integers instead of floats/doubles.
what programming language do you use?
Thank you.
- stijn263
- Posts: 1505
- Joined: Sat Sep 15, 2007 11:57 pm
- Location: Netherlands
Re: Problem 2
Yup, you should avoid using doubles unless you have a good reason for using them. All projecteuler problems have answers smaller than 263, so using long long int will be sufficient.
If you're using cout to output your numbers, you can change the precision of the double output by setting: cout.precision(15);
Ints will always be fully shown.
If you're using cout to output your numbers, you can change the precision of the double output by setting: cout.precision(15);
Ints will always be fully shown.
-
phillyj
- Posts: 2
- Joined: Fri Oct 15, 2010 9:10 pm
Problem 002
Hi, I looked over a previous post on #2 but I'm still confused. In my understanding, am I to find:
[1] the sum of all the even numbers and the sum should be less than or equal to 4 million?
[2] the sum of the even numbers under each of which is less than or equal to 4 million? In this case, the answer can be greater than 4 million.
Which way am I supposed to solve it?
Thank you
[1] the sum of all the even numbers and the sum should be less than or equal to 4 million?
[2] the sum of the even numbers under each of which is less than or equal to 4 million? In this case, the answer can be greater than 4 million.
Which way am I supposed to solve it?
Thank you
-
Susanne
- Posts: 32
- Joined: Sun Nov 08, 2009 7:39 am
Re: Problem 002
It is case [2]. Each of the numbers must be smaller or equal 4 million.
Last edited by Susanne on Fri Oct 15, 2010 10:53 pm, edited 1 time in total.

-
phillyj
- Posts: 2
- Joined: Fri Oct 15, 2010 9:10 pm
Re: Problem 002
I give up...for today. I thought I got the numbers but I keep getting it wrong. My code must be bad. I'm using matlab.