Paste: project euler 2

Author: logloglogloglog
Mode: factor
Date: Mon, 22 Dec 2014 01:49:53
Plain Text |
 
 USE: combinators
 USE: memoize
 MEMO: fib ( x -- fib(x) )
     {
         { [ dup 0 = ] [ drop 1 ] }
         { [ dup 1 = ] [ drop 1 ] }
         [ [ 2 - fib ] [ 1 - fib ] bi + ]
      } cond
      ; inline recursive
  
  
: euler-002 ( x -- x )
       [1,b] ! infinite seq here instead of range
       [ fib ] map
       [ 4000000 < ] filter
       [ even? ] filter
       sum
      ; 

New Annotation

Summary:
Author:
Mode:
Body: