--- a/src/euler.lisp Wed Feb 22 18:01:30 2017 +0000
+++ b/src/euler.lisp Wed Feb 22 18:08:30 2017 +0000
@@ -825,6 +825,25 @@
;; don't double-count the center...
(- (aref spiral (truncate size 2) (truncate size 2))))))
+(defun problem-29 ()
+ ;; Consider all integer combinations of a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:
+ ;;
+ ;; 2²=4, 2³=8, 2⁴=16, 2⁵=32
+ ;; 3²=9, 3³=27, 3⁴=81, 3⁵=243
+ ;; 4²=16, 4³=64, 4⁴=256, 4⁵=1024
+ ;; 5²=25, 5³=125, 5⁴=625, 5⁵=3125
+ ;;
+ ;; If they are then placed in numerical order, with any repeats removed, we
+ ;; get the following sequence of 15 distinct terms:
+ ;;
+ ;; 4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
+ ;;
+ ;; How many distinct terms are in the sequence generated by a^b for
+ ;; 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?
+ (length (iterate (for-nested ((a :from 2 :to 100)
+ (b :from 2 :to 100)))
+ (adjoining (expt a b)))))
+
;;;; Tests --------------------------------------------------------------------
(def-suite :euler)
@@ -858,6 +877,7 @@
(test p26 (is (= 983 (problem-26))))
(test p27 (is (= -59231 (problem-27))))
(test p28 (is (= 669171001 (problem-28))))
+(test p29 (is (= 9183 (problem-29))))
;; (run! :euler)