So, in my first attempt I created a code that generated all fibonacci numbers and appended to a list. This list I then traversed to get the even numbers and added them up. It worked, but took like 5 complete seconds to work. Then I decided to not create a list and add the even numbers as I'm generating them. It looked like this
a = 1 b = 1 c = 0 Sum = 0 while c<4000000: c = a + b if c%2==0: Sum+=c a = b b = c print Sum It still took quite a lot of time (didn't record it) compared to the people who got it done in like 100 milliseconds or something (I got this question on Project Euler). Is there a way to make it faster? Here's the link to the problem