This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
project-euler/e0002/euler0002.rkt

13 lines
328 B
Racket
Raw Normal View History

2017-05-09 19:20:46 +02:00
#lang racket
(define (fib i)
(cond [(equal? 0 i) 1]
[(equal? 1 i) 2]
(else (+ (fib (- i 1))(fib (- i 2))))))
(define (fiblist it limit lst)
(cond [(equal? limit it) lst]
(else (fiblist (+ it 1) limit
(cons (fib it) lst)))))
(foldl + 0 (filter even? (fiblist 0 4000000 '())))