Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Charge through a few more problems with scant regard for correctness!

  • Loading branch information...
commit 97e63cc6c8c68d88b2d47ea3aa4f3051afafb143 1 parent 603f310
@fffej authored
Showing with 24 additions and 1 deletion.
  1. +24 −1 99.clj
View
25 99.clj
@@ -248,5 +248,28 @@
(defn prime-factors [x]
(prime-factors-fn x (prime-factors-helper x)))
-
+;; P36 Prime factors of a given positive integer + multiplicands
+(defn prime-factors-mult [x]
+ (let [y (prime-factors x)]
+ (map (fn [x] (if (list? x) x (list x 1))) (encode-direct y))))
+
+;; P37 Improved totient function
+(defn totient-improved [m]
+ (let [factors (prime-factors-mult m)]
+ (reduce + (map
+ (fn [x]
+ (let [p (first x) m (second x)]
+ (* (dec p) (Math/pow p (dec m)))))
+ factors))))
+
+;; P38
+
+;; P39 A list of prime numbers
+(defn primes [x y]
+ (filter (fn [z] (< x z)) (sieve y)))
+
+;; P40 Goldbach's conjecture
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.