Summarize primes: Difference between revisions

Content deleted Content added
CalmoSoft (talk | contribs)
No edit summary
Chunes (talk | contribs)
Add Factor
Line 4: Line 4:
Summarize first n primes (p) and check if it is a prime, where '''p < 1000'''
Summarize first n primes (p) and check if it is a prime, where '''p < 1000'''
<br><br>
<br><br>

=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
<lang factor>USING: assocs formatting kernel math.primes math.ranges
math.statistics prettyprint ;

1000 [ [1,b] ] [ primes-upto cum-sum ] bi zip
[ nip prime? ] assoc-filter
[ "The sum of the first %3d primes is %5d (which is prime).\n" printf ] assoc-each</lang>
{{out}}
<pre>
The sum of the first 1 primes is 2 (which is prime).
The sum of the first 2 primes is 5 (which is prime).
The sum of the first 4 primes is 17 (which is prime).
The sum of the first 6 primes is 41 (which is prime).
The sum of the first 12 primes is 197 (which is prime).
The sum of the first 14 primes is 281 (which is prime).
The sum of the first 60 primes is 7699 (which is prime).
The sum of the first 64 primes is 8893 (which is prime).
The sum of the first 96 primes is 22039 (which is prime).
The sum of the first 100 primes is 24133 (which is prime).
The sum of the first 102 primes is 25237 (which is prime).
The sum of the first 108 primes is 28697 (which is prime).
The sum of the first 114 primes is 32353 (which is prime).
The sum of the first 122 primes is 37561 (which is prime).
The sum of the first 124 primes is 38921 (which is prime).
The sum of the first 130 primes is 43201 (which is prime).
The sum of the first 132 primes is 44683 (which is prime).
The sum of the first 146 primes is 55837 (which is prime).
The sum of the first 152 primes is 61027 (which is prime).
The sum of the first 158 primes is 66463 (which is prime).
The sum of the first 162 primes is 70241 (which is prime).
</pre>


=={{header|Ring}}==
=={{header|Ring}}==