Anonymous user
Sequence of primes by trial division: Difference between revisions
Sequence of primes by trial division (view source)
Revision as of 10:20, 2 October 2017
, 6 years ago→{{header|Eiffel}}
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>
|