Skip to content

Instantly share code, notes, and snippets.

@kupp1
Last active June 10, 2019 19:32
Show Gist options
  • Save kupp1/5aeec00962211cd1be132192fc7a3d95 to your computer and use it in GitHub Desktop.
Save kupp1/5aeec00962211cd1be132192fc7a3d95 to your computer and use it in GitHub Desktop.
Matt Parker per function from https://www.youtube.com/watch?v=Wim9WJeDTHQ written on common lisp
(defun div(n d)
(multiple-value-bind (q r) (floor n d) q))
(defun per(n)
(if (= n (rem n 10))
(format t "~d~%" n)
(progn
(format t "~d->" n)
(setq mul 1)
(loop while (> n 0) do
(progn
(setq d (rem n 10))
(setq mul (* mul d))
(setq n (div n 10))))
(format t "~d~%" mul)
(per mul))))
(per 277777788888899)
(bye)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment