My answer to this problem seems too similar to these solutions in C.
Does anyone have any tips to make this more lazy?
(use 'clojure.test) (:import 'java.lang.Math) (with-test (defn find-triplet-product ([target] (find-triplet-product 1 1 target)) ([ab target] (let [c (Math/sqrt (+ (* aa) (* bb)))] (let [sum (+ abc)] (cond (> a target) "ERROR" (= sum target) (reduce * (list ab (int c))) (> sum target) (recur (inc a) 1 target) (< sum target) (recur a (inc b) target)))))) (is (= (find-triplet-product 1000) 31875000)))
clojure
dbyrne
source share