Euler problem 6.1

— by this meme’s creator

.

(defun range (max &key (min 0) (step 1))
  (loop :for n :from min :below max :by step
    collect n))

(defun sum-1-n (n)
  (/ (* n (+ n 1)) 2))

(defun sum (lst)
  (reduce #'+ lst))

(defun square (x)
  (* x x))

(- (square (sum-1-n 100))
   (sum (mapcar #'square (range 101 :min 1))))

; 25164150

.

— Me@2022-10-29 06:39:07 AM

.

.

2022.10.29 Saturday (c) All rights reserved by ACHK