Sieve of Eratosthenes: Difference between revisions

Line 1,287:
The required list of prime divisors obtains by recursion (<tt>{⍵/⍳⍴⍵}∇⌈⍵*0.5</tt>).
 
=== Optimized Version ===|
 
<syntaxhighlight lang="apl">sieve←{
Line 1,323:
The last expression computes the number of primes < 1e0 1e1 ... 1e9.
The last number 50847534 can perhaps be called the anti-Bertelsen's number (http://mathworld.wolfram.com/BertelsensNumber.html).
 
=== Absolutely non-optimized Version ===|
 
<syntaxhighlight lang="apl">sieve←{1⊖⍵~(1↑⍵)×1↓⍳⍴⍵}⍣{2=1↑⍺}1↓⍳⍵</syntaxhighlight>
 
Step by step.
 
<pre>[2] 3 4 5 6 7 8 9 10 11
3 5 7 9 11 [2]
5 7 11 [2] 3
7 11 [2] 3 5
11 [2] 3 5 7
[2] 3 5 7 11</pre>
 
=={{header|AppleScript}}==
422

edits