in reply to (Golf): Sieve of Eratosthenes
57 characters:
58 characters, strict-compliant:sub sieve { my@p;@_=2..pop;{push@p,$p=shift;redo if@_=grep$_%$p,@_}@p }
BTW, what is the Big-O of the Sieve of Eratosthenes? :)sub sieve { my@p;@_=2..pop;{push@p,shift;redo if@_=grep$_%$p[-1],@_}@p }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: (Golf): Sieve of Eratosthenes
by tilly (Archbishop) on May 19, 2001 at 21:20 UTC |