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.
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
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.
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 evenvalued 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 my english is bad ...
and I don't understand really
"Find the sum of all the evenvalued 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 !
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.
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 ...)

 Posts: 2
 Joined: Sat Oct 25, 2008 9: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 10:24 pm, edited 1 time in total.
Reason: Remove code and answer
Reason: Remove code and answer
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 10: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à.

 Posts: 2
 Joined: Sat Oct 25, 2008 9: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
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.

 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?
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

 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).
Re: Problem 2
try using integers instead of floats/doubles.
what programming language do you use?
what programming language do you use?

 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?

 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.
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 2^{63}, 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.
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
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 9:53 pm, edited 1 time in total.
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.