Last active
November 23, 2018 20:30
-
-
Save shayelkin/29711f9306df183bd745a56644860958 to your computer and use it in GitHub Desktop.
Ratio of non primes naturals <100 that only have primary divisors
This file contains hidden or 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
;; https://twitter.com/sartanbegavhaum/status/1066051737650429952 | |
(defn non-trivial-factors [n] | |
(filter #(zero? (mod n %)) (range 2 n))) | |
(def prime? (comp empty? non-trivial-factors)) | |
(defn tomer-number? [n] | |
(when-let [facts (seq (non-trivial-factors n))] | |
(every? prime? facts))) | |
(/ (count (filter tomer-number? (range 2 100))) | |
(count (remove prime? (range 2 100)))) | |
;; => 34/73 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment