PCPOTATO
Navigation

Home
About
Contact
Resume

Projects

None yet

Categories

General
Interesting
Programming

Archives

August 2008
July 2008
June 2008
May 2008
April 2008
Project Euler #2 April 13th, 2008

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.

Leave a Reply

You must be logged in to post a comment.

Domains


Links


Presence


Meta

Log in