utils.lisp @ ef04c7b3d0b8

Problem 10, Miller-Rabin, etc
author Steve Losh <steve@stevelosh.com>
date Mon, 11 Apr 2016 14:40:47 +0000
parents 3512c67e0138
children (none)
(in-package #:euler.utils)

(defun random-exclusive (min max)
  "Return an integer in the range (`min`, `max`)."
  (+ 1 min (random (- max min 1))))

(defun dividesp (n divisor)
  "Return whether `n` is evenly divisible by `divisor`."
  (zerop (mod n divisor)))


(defmacro repeat (n &body body)
  "Repeat `body` `n` times."
  `(dotimes (,(gensym) ,n)
     ,@body))