News for hackers. Stuff that matters.
Re:Can you solve it? The Greplin programming challenge by kasterma on Sunday October 10, 2010 @10:08AM (#1777102)
Here (where you have to search through Fibonacci numbers) I suspect memoization is rather the way to go:

  # memoized fibonacci function
  fibtable = {1:1, 0:1}

  def fib (n):
      global fibtable
      if n in fibtable.keys():
          return fibtable [n]
      val = fib (n-1) + fib (n-2)
      fibtable [n] = val
      return val
Re:Can you solve it? The Greplin programming challenge by btilly on Sunday October 10, 2010 @11:54AM (#1777237)
There is no need to keep track of all previous values.

  last_fib = 0
  fib = 1
  while fib < 225000 or not is_prime(fib):
    last_fib, fib = fib, last_fib + fib