Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Re: Re: (Golf): Sieve of Eratosthenes

by MeowChow (Vicar)
on May 19, 2001 at 21:56 UTC ( #81741=note: print w/ replies, xml ) Need Help??

in reply to Re: Re: (Golf): Sieve of Eratosthenes
in thread (Golf): Sieve of Eratosthenes

I had thought of that, but assumed it would slide :)

Make that 46 by the way...

sub sieve { sub p{$_[0],$#_?p(grep$_%$_[0],@_):()}p 2..pop }
               s aamecha.s a..a\u$&owag.print

Comment on Re: Re: Re: (Golf): Sieve of Eratosthenes
Download Code
Replies are listed 'Best First'.
Re: Re: Re: Re: (Golf): Sieve of Eratosthenes
by chipmunk (Parson) on May 19, 2001 at 22:00 UTC
    I had thought of that, but that goes into deep recursion if you call sieve(1). :)

    Oh, but tilly says that you may assume $n is above a fixed number. Pooh!

      No. I only say that for the bonus problem.

      The first problem is correct first, efficient afterwards. The second should express the efficient algorithm accurately, but I allow some boundary sloppiness.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://81741]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-30 20:39 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (273 votes), past polls