82da42a326e4

Problem 56
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 27 Feb 2017 01:22:47 +0000
parents ac65fcda590f
children 42598a2717eb
branches/tags (none)
files src/euler.lisp

Changes

--- a/src/euler.lisp	Mon Feb 27 01:15:50 2017 +0000
+++ b/src/euler.lisp	Mon Feb 27 01:22:47 2017 +0000
@@ -1428,6 +1428,17 @@
 
 
 
+(defun problem-56 ()
+  ;; A googol (10^100) is a massive number: one followed by one-hundred zeros;
+  ;; 100^100 is almost unimaginably large: one followed by two-hundred zeros.
+  ;; Despite their size, the sum of the digits in each number is only 1.
+  ;;
+  ;; Considering natural numbers of the form, a^b, where a, b < 100, what is the
+  ;; maximum digital sum?
+  (iterate (for-nested ((a :from 1 :below 100)
+                        (b :from 1 :below 100)))
+           (maximizing (funcall #'sum (digits (expt a b))))))
+
 (defun problem-74 ()
   ;; The number 145 is well known for the property that the sum of the factorial
   ;; of its digits is equal to 145:
@@ -1519,5 +1530,8 @@
 (test p47 (is (= 134043 (problem-47))))
 (test p48 (is (= 9110846700 (problem-48))))
 
+(test p56 (is (= 972 (problem-56))))
+(test p74 (is (= 402 (problem-74))))
+
 
 ;; (run! :euler)