From: Roelof Wobben Date: 2012-09-29T03:35:51+09:00 Subject: ibonacci sequence problem --_1b8721ff-f6ec-48fd-9c44-346b860368d0_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello=2C=20 I have this problem. By considering the terms in the Fibonacci sequence whose values do not=20 exceed four million=2C find the sum of the even-valued terms. So i was thinking of solving it this way 1) n =3D Array.new [1=2C2] 2) while n[-1] + n[-2] < 4000000 do=20 n << n[-2] + n[-1] end So I have now all the numbers. 3) n.inject { |sum=2C number| if number%2 =3D=3D 0 then sum + number else s= um end} I see a answer but according to the site it's wrong. Can anyone tell me where I'm thinking wrong ? Roelof = --_1b8721ff-f6ec-48fd-9c44-346b860368d0_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello=2C

I have this problem.

By considering the terms in th= e Fibonacci sequence whose values do not=20 exceed four million=2C find the sum of the even-valued terms.

So i w= as thinking of solving it this way

1) n =3D Array.new [1=2C2]
2) while n[-1] + n[-2] <=3B 4000000 do
 =3B =3B =3B n &l= t=3B<=3B n[-2] + n[-1]
end

So I have now all the numbers.
3) n.inject { |sum=2C number| if number%2 =3D=3D 0 then sum + number else= sum end}

I see a answer but according to the site it's wrong.
Can anyone tell me where I'm thinking wrong ?

Roelof


=
= --_1b8721ff-f6ec-48fd-9c44-346b860368d0_--