The sum of all of the even-valued terms in the sequence which do not exceed four million.
1 2 3 4 5 6 7 8 9 10 11 12 13 | sum = 0 first = 1 second = 1 current = 2 while(current < 4000000): if (current %2 == 0): sum = sum + current first = second second = current current = current + first print current, print sum |
Efficiency and I do not get along.