Jump to content

Sequence of primes by trial division: Difference between revisions

m (→‎more optimized: made a couple of cosmetic changes.)
Line 669:
19
23
</pre>
=={{header|Elena}}==
ELENA 3.2.1 :
<lang elena>import extensions.
import system'routines.
import system'math.
 
isPrime =
(:n)(Range new(2,(n sqrt - 1) roundedInt); allMatchedBy(:i)(n mod:i != 0)).
 
Primes =
(:n)(Range new(2, n - 2); filterBy:isPrime; toArray).
program =
[
console printLine(Primes eval:100).
].</lang>
{{out}}
<pre>
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97
</pre>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.