Subject: Re: Another Newbie Question !!!
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 06 Dec 2008 20:05:47 -0600
Newsgroups: comp.lang.lisp
Message-ID: <8v2dnQVs7PPmsqbUnZ2dnUVZ_sHinZ2d@speakeasy.net>
William James <w_a_x_man@yahoo.com> wrote:
+---------------
| Nicolas Neuss wrote:
| > BTW, is this one allowed?
| > (defun find-factors (number)
| >   (loop with root = (isqrt number)
| >      for i from 2 while (<= i root)
| >        when (zerop (rem number i))
| >        do (return-from find-factors
| >             (cons i (find-factors (/ number i)))))
| >   (list number))
| > 
| > (time (find-factors 600851475143))  ; SBCL
...
| > (71 839 1471 6857)
| 
| Correct results:
| 
| 71 839 1471 6857 59569 104441 486847 
+---------------

Depends on what you mean by "correct". Nicolas's answer is
correct inasmuch as (* 71 839 1471 6857) ==> 600851475143.

Your answer repeats factors that have already been accounted
for earlier:

     59569 = (* 71 839)
    104441 = (* 71 1471)
    486847 = (* 71 6857)


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607