Project Euler Problem 12
For function problem12, every time it loops, it calculates the next triangle number (i). It keeps looping until it reaches a triangle number that has over 500 factors.
(defun how-many-factors? (num)
(* 2 (loop for i from 1 to (isqrt num)
if (zerop (mod num i))
count i)))
(defun problem12 ()
(loop for i = 1 then (+ i j)
and j upfrom 2
when (> (how-many-factors? i) 500)
return i))
No comments:
Post a Comment