# HG changeset patch # User Steve Losh # Date 1488156437 0 # Node ID 735c2b5c943016c475cbfcff57bff44307aa971d # Parent 6124d264353e0a25bf79150fe6c93b2660846e8c Problem 47 diff -r 6124d264353e -r 735c2b5c9430 src/euler.lisp --- 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)