45b4d825074f

Problem 48
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 27 Feb 2017 00:51:33 +0000
parents 735c2b5c9430
children ac65fcda590f
branches/tags (none)
files src/euler.lisp

Changes

--- a/src/euler.lisp	Mon Feb 27 00:47:17 2017 +0000
+++ b/src/euler.lisp	Mon Feb 27 00:51:33 2017 +0000
@@ -1417,6 +1417,15 @@
         (setf run 0))
       (finding (- i 3) :such-that (= run 4)))))
 
+(defun problem-48 ()
+  ;; The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
+  ;;
+  ;; Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
+  (-<> (range 1 (1+ 1000))
+    (mapcar #'expt <> <>)
+    sum
+    (mod <> (expt 10 10))))
+
 
 ;;;; Tests --------------------------------------------------------------------
 (def-suite :euler)
@@ -1469,6 +1478,7 @@
 (test p45 (is (= 1533776805 (problem-45))))
 (test p46 (is (= 5777 (problem-46))))
 (test p47 (is (= 134043 (problem-47))))
+(test p48 (is (= 9110846700 (problem-48))))
 
 
 ;; (run! :euler)