Skip to content

Instantly share code, notes, and snippets.

@vermiculus
Last active August 29, 2015 14:16
Show Gist options
  • Save vermiculus/baec521ac3ec06307c17 to your computer and use it in GitHub Desktop.
Save vermiculus/baec521ac3ec06307c17 to your computer and use it in GitHub Desktop.
(defun tmp:to-string (base to-power)
(when (< 0 to-power)
(concat
(tmp:to-string base (1- to-power))
(number-to-string
(* base to-power)))))
(defun tmp:do-concat (base to-power)
(string-to-number
(tmp:to-string
base to-power)))
(defun tmp:basep (n base &optional power)
(let ((power (or power 1)))
(let ((result (tmp:do-concat base power)))
(cond
((= n result) base)
((< n result) 'too-big)
(t (tmp:basep n base (1+ power)))))))
(defun tmp:p (n &optional base)
(let ((base (or base 2))
(result 'too-big))
(while (eq result 'too-big)
(setq result (tmp:basep n base))
(setq base (1+ base)))
(1- base)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment