Paste: Euler 2

Author: max
Mode: factor
Date: Fri, 17 Feb 2012 16:38:45
Plain Text |
IN: fibo
USING: kernel math math.parser io sequences locals ;

: next-fibo ( x y -- y x+y ) swap over + ; foldable flushable inline
:: fibo-max ( max -- seq ) 1 1 [ next-fibo over max <= ] [ over ] produce 2nip ; foldable flushable
: even-fibo-sum ( max -- sum ) fibo-max [ even? ] filter sum ;
: print-euler2 ( -- ) 4000000 even-fibo-sum number>string print ;

MAIN: print-euler2

New Annotation

Summary:
Author:
Mode:
Body: