Skip to content

Instantly share code, notes, and snippets.

@furushchev
Created June 4, 2013 16:07
Show Gist options
  • Save furushchev/5707188 to your computer and use it in GitHub Desktop.
Save furushchev/5707188 to your computer and use it in GitHub Desktop.
Project Euler Problem12 Too slow T_T
(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