Page 1 of 3
Problem 002
Posted: Sun Mar 02, 2008 9:02 pm
by newinkles
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
Re: Problem 2
Posted: Sun Mar 02, 2008 9:52 pm
by hk
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.
problem 2 help please translate or example ...
Posted: Thu Apr 10, 2008 7:20 pm
by kinyel
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 !
Re: problem 2 help please translate or example ...
Posted: Thu Apr 10, 2008 7:26 pm
by hk
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.
Re: problem 2 help please translate or example ...
Posted: Thu Apr 10, 2008 7:38 pm
by kinyel
thank you very, very much !
(never I think this and automatic translate don't give this ...)
Problem 2 -- What the heck ?
Posted: Sat Oct 25, 2008 11:12 pm
by dgiancaspro
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
Re: Problem 2 -- What the heck ?
Posted: Sat Oct 25, 2008 11:19 pm
by xan
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.
Re: Problem 2 -- What the heck ?
Posted: Sat Oct 25, 2008 11:31 pm
by daniel.is.fischer
Whether it was a copy/paste slip or a server glitch, please try again and if that doesn't work, notify us.
Re: Problem 2 -- What the heck ?
Posted: Sun Oct 26, 2008 1:10 am
by dgiancaspro
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
Re: Problem 2
Posted: Sat Nov 22, 2008 8:16 pm
by hk
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.
Re: Problem 2
Posted: Fri Nov 28, 2008 7:49 pm
by chinesefishmarket
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?
Re: Problem 2
Posted: Fri Nov 28, 2008 8:38 pm
by ed_r
Probably. Keep plugging away at it; you'll get there in the end. Good luck
(please note: this is not a hints forum!)
Re: Problem 2
Posted: Fri Nov 28, 2008 9:19 pm
by chinesefishmarket
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).
Re: Problem 2
Posted: Fri Nov 28, 2008 9:22 pm
by stijn263
try using integers instead of floats/doubles.
what programming language do you use?
Re: Problem 2
Posted: Fri Nov 28, 2008 9:25 pm
by chinesefishmarket
stijn263 wrote:try using integers instead of floats/doubles.
what programming language do you use?
C++
Re: Problem 2
Posted: Fri Nov 28, 2008 9:27 pm
by chinesefishmarket
chinesefishmarket wrote:stijn263 wrote:try using integers instead of floats/doubles.
what programming language do you use?
C++
OK. Forcing everything to be int works out great.
Thank you.
Re: Problem 2
Posted: Sat Nov 29, 2008 10:41 am
by stijn263
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.
Problem 002
Posted: Fri Oct 15, 2010 9:16 pm
by phillyj
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
Re: Problem 002
Posted: Fri Oct 15, 2010 9:44 pm
by Susanne
It is case [2]. Each of the numbers must be smaller or equal 4 million.
Re: Problem 002
Posted: Fri Oct 15, 2010 9:56 pm
by phillyj
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.