fork download
  1. import itertools
  2.  
  3.  
  4. def fibonacci():
  5. a, b = 0, 1
  6. while True:
  7. yield b
  8. a, b = b, a+b
  9.  
  10. fib=fibonacci()
  11.  
  12. sum_ = sum([n for n in itertools.takewhile(lambda x: x < 400, fib)])
  13. print sum_
  14. # your code goes here
Success #stdin #stdout 0.01s 7852KB
stdin
Standard input is empty
stdout
986