Out of the gates in a hurry!

by

Well, I had already tried a bunch of these guys, and I want to try out this posting deal, so here’s my solutions to the first two.


#
#  problem1.py
#

nums = set(i for i in range(1,1000) if ((i%3 == 0) or (i%5 == 0)))

print sum(nums)

#
#  problem2.py
#

fib_last = 1
fib_cur = 1

ev_sum = 0

def isEven(num):
return (num % 2 == 0)

while fib_cur <= 4000000: if isEven(fib_cur): ev_sum += fib_cur temp = fib_cur fib_cur += fib_last fib_last = temp print ev_sum [/sourcecode]

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: