Created
June 4, 2013 16:07
-
-
Save furushchev/5707188 to your computer and use it in GitHub Desktop.
Project Euler Problem12
Too slow T_T
This file contains 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 sum-n (n) | |
(if (= n 1) | |
1 | |
(+ n (sum (- n 1))))) | |
(defun check-div (num) | |
(labels ((check-div-r (n k) | |
(if (= k 1) | |
1 | |
(if (integerp (/ n k)) | |
(1+ (check-div-r n (1- k))) | |
(check-div-r n (1- k)))))) | |
(check-div-r num num))) | |
(defun prob-12 (num) | |
(do ((i 1 (1+ i)) (result 0)) | |
((> result num) (format t "ans: ~A~%" (sum-n (1- i)))) | |
(setq result (check-div (sum-n i))) | |
)) | |
(time (prob-12 500)) ;; 時間がかかりすぎてとけましぇん(´・ω・`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment