sub Eratosthenes_Sieve($) { for(@a=(1)x($_[0]+1),$p=2;$p**2<$_[0];){for($j=2*$p;$j<$_ [0];$j+=$p){$a[$j]=0}for($a[++$p]){}}grep{$a[$_]}(2..$#a) }
I've made it tricky to read, and concise, I just loved the concept.
I'm not saying give up using Pari ;), it just amazed me that this
equation was found two and a quarter millenia ago, ain't Maths cool.
Don't worry your RSA keys are safe, 32 Bit encryption will render:
four thousand, two hundred and ninetyfour million nine hundred
and sixtyseven thousand two hundred and ninetysix digits ;)
Update: It's been done before :(, needless to say far better too, especially meowchow..
--
Brother Frankus.
¤
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Eratosthenes Sieve
by IraTarball (Monk) on Oct 22, 2001 at 20:54 UTC |