Created
November 9, 2013 02:16
-
-
Save johnwalker/7380708 to your computer and use it in GitHub Desktop.
#12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns highly-divisible-triangle-numbers | |
(:require [clojure.core.reducers :as r])) | |
(def triangles (reduce | |
(fn [x y] | |
(conj x (+ (peek x) y))) | |
[0] | |
(range 1 20000))) | |
(defn factors [n] | |
(into (sorted-set) | |
(reduce concat | |
(for [x (range 1 (inc (Math/sqrt n))) :when (zero? (rem n x))] | |
[x (/ n x)])))) | |
(doseq [sol (filter #(> (count (factors %)) 500) triangles)] | |
(println sol)) | |
(count (factors 76576500)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I kind of stole the factoring code though. But really. I've written enough of those to know that I don't want to write them.