News for hackers. Stuff that matters.
Re:Python vs Clojure by d0mine on Wednesday October 14, 2009 @05:58PM (#882235)
There is a bug in the fibonacci example: it sums odd numbers instead of even.

  from itertools import takewhile
  
  def ifibonacci(a=1, b=1):
      while True:
          yield a
          a, b = b, a + b
  
  candidates = takewhile(lambda n: n < 4000000, ifibonacci())        
  print sum(n for n in candidates if n % 2 == 0)

There are no comments on this comment yet.