Guest User

Untitled

a guest
Oct 16th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. def fib(x):
  2. seq = [0]
  3. fib = 0
  4. while fib < x:
  5. if len(seq) == 1:
  6. seq.append(1)
  7. else:
  8. fib = seq[-1] + seq[-2]
  9. seq.append(fib)
  10. seq.remove(fib)
  11. return seq
  12. length = raw_input("Up to what number? ")
  13. fiblist = fib(int(length))
  14. i = 0
  15. while i < len(fiblist):
  16. if fiblist[i] % 2 == 1:
  17. fiblist.remove(fiblist[i])
  18. else:
  19. i = i + 1
  20. print sum(fiblist)
Add Comment
Please, Sign In to add comment