Bu problem cevabım bu solutions in C gibi çok fazla hissediyor.Proje Euler # 9 (Pisagor üçlü) Clojure içinde
Bunu daha fazla dil bilen birisi var mı?
(use 'clojure.test)
(:import 'java.lang.Math)
(with-test
(defn find-triplet-product
([target] (find-triplet-product 1 1 target))
([a b target]
(let [c (Math/sqrt (+ (* a a) (* b b)))]
(let [sum (+ a b c)]
(cond
(> a target) "ERROR"
(= sum target) (reduce * (list a b (int c)))
(> sum target) (recur (inc a) 1 target)
(< sum target) (recur a (inc b) target))))))
(is (= (find-triplet-product 1000) 31875000)))
Büyük kaynak ... teşekkürler bana öyle geliyor. Bağlantı için – dbyrne
+1! –