Lisp Min Perimeter Rectangle
(defun min-perimeter-rectangle (n)
(let ((i 1)
(min most-positive-fixnum))
(loop while (< (* i i) n)
do (progn
(when (zerop (mod n i))
(setf min (min min (* 2 (+ i (/ n i))))))
(incf i)))
min))
This searches factor pairs up to the square root and picks the pair with the smallest perimeter.