Skip to content

Instantly share code, notes, and snippets.

@even4void
Created September 21, 2019 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save even4void/b839d4b99d53a7fd9d6b84681efb7e0f to your computer and use it in GitHub Desktop.
Save even4void/b839d4b99d53a7fd9d6b84681efb7e0f to your computer and use it in GitHub Desktop.
#lang racket
;; Euler problem 15
(define (reduce f xs)
(and (not (empty? xs)) (foldl f (first xs) (rest xs))))
(define (f n)
(reduce (lambda (x y) (* x y)) (range 1 (add1 n))))
(define (sol-015 [n 20])
(ceiling (/ (f (* n 2)) (f n) (f n))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment