# Re: Multiple arguments to mapcar?

• From: "Steven M. Haflich" <smh@xxxxxxxxxxxx>
• Date: Tue, 06 Nov 2007 09:49:44 GMT

Pascal: Here's a neat example of using of loop to solve a well-understood problem in a nonobvious way...

(defun primes-below-limit (limit)
(cons 2
(loop for i from 3 by 2 below limit
unless (loop for p in primes
when (integerp (/ i p)) return t)
collect i into primes
finally (return primes))))

I think this is portable and correct, provided limit >= 2.
.

## Relevant Pages

• Re: First Program Bug (Newbie)
... I used the incrementing command and incremented candidates by two to check only odds and now the program is a lot faster. ... head to write a program to print all the primes; ... The program prints some non-prime numbers. ... outer while loop: ...
(comp.lang.python)
• Re: First Program Bug (Newbie)
... head to write a program to print all the primes; ... The program prints some non-prime numbers. ... outer while loop: ... throw this away and use gmpy. ...
(comp.lang.python)
• Re: First Program Bug (Newbie)
... Although Python has built in Big ... the gmpy versions can sometimes run rings around ... All these false primes ... outer while loop: ...
(comp.lang.python)
• Re: Multiple arguments to mapcar?
... (defun primes-below-limit (limit) ... (loop for i from 3 by 2 below limit ... unless (loop for p in primes ... when (integerp (/ i p)) return t) ...
(comp.lang.lisp)
• Re: [Algorithm] Sum of Primes < 1000000
... I saw no attack in Simon's post. ... The set was of primes, and the size of that is O, so 1/4 of that is O. ... For each p reached that's not gotten marked composite earlier, loop from p^2 until N step p. ... I concluded that the average length of the loop is bounded by O, and the whole algorithm by O. ...
(comp.lang.java.programmer)