Last active
June 10, 2019 19:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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