Paste: fibonacci

Author: ditto
Mode: factor
Date: Sat, 14 Feb 2009 07:17:48
Plain Text |
USING: locals ;

:: next-fib-seq ( seq -- newseq )
  [let | next-term [ seq 2 tail* sum ] | seq next-term suffix ] ;

:: fib-seq-exceed? ( seq -- ? )
  seq peek 4000000 > ;

:: fib-seq ( seq -- newseq )
  [let | next [ seq next-fib-seq ] |
  next fib-seq-exceed? [ seq ] [ next fib-seq ] if ] ;

: solve ( -- )
  { 1 2 } fib-seq [ even? ] filter sum .

New Annotation

Summary:
Author:
Mode:
Body: