--- a/src/euler.lisp Mon Feb 27 00:38:16 2017 +0000
+++ b/src/euler.lisp Mon Feb 27 00:47:17 2017 +0000
@@ -1393,6 +1393,30 @@
(finding i :such-that (and (compositep i)
(counterexamplep i))))))
+(defun problem-47 ()
+ ;; The first two consecutive numbers to have two distinct prime factors are:
+ ;;
+ ;; 14 = 2 × 7
+ ;; 15 = 3 × 5
+ ;;
+ ;; The first three consecutive numbers to have three distinct prime factors are:
+ ;;
+ ;; 644 = 2² × 7 × 23
+ ;; 645 = 3 × 5 × 43
+ ;; 646 = 2 × 17 × 19
+ ;;
+ ;; Find the first four consecutive integers to have four distinct prime
+ ;; factors each. What is the first of these numbers?
+ (flet ((factor-count (n)
+ (length (remove-duplicates (prime-factorization n)))))
+ (iterate
+ (with run = 0)
+ (for i :from 1)
+ (if (= 4 (factor-count i))
+ (incf run)
+ (setf run 0))
+ (finding (- i 3) :such-that (= run 4)))))
+
;;;; Tests --------------------------------------------------------------------
(def-suite :euler)
@@ -1444,6 +1468,7 @@
(test p44 (is (= 5482660 (problem-44))))
(test p45 (is (= 1533776805 (problem-45))))
(test p46 (is (= 5777 (problem-46))))
+(test p47 (is (= 134043 (problem-47))))
;; (run! :euler)