Created
November 7, 2011 19:14
-
-
Save hidsh/1345854 to your computer and use it in GitHub Desktop.
桁数を求める for xyzzy
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 digit (n) | |
"return digit for number." | |
(setq n (truncate (1+ n))) | |
(let ((d 0)) | |
(while (> n 1) | |
(setq n (/ n 10)) | |
(incf d)) | |
d)) | |
;; (digit 1000) | |
;; =>4 | |
;; (digit 999) | |
;; =>3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment