Summarize primes: Difference between revisions
Content deleted Content added
Realize in F# |
|||
Line 5: | Line 5: | ||
<br><br> |
<br><br> |
||
=={{header|F_Sharp|F#}}== |
|||
This task uses [http://www.rosettacode.org/wiki/Extensible_prime_generator#The_functions Extensible Prime Generator (F#)] |
|||
<lang fsharp> |
|||
// Summarize Primes: Nigel Galloway. April 16th., 2021 |
|||
primes32()|>Seq.takeWhile((>)1000)|>Seq.scan(fun(n,g) p->(n+1,g+p))(0,0)|>Seq.filter(snd>>isPrime)|>Seq.iter(fun(n,g)->printfn "%3d->%d" n g) |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
1->2 |
|||
2->5 |
|||
4->17 |
|||
6->41 |
|||
12->197 |
|||
14->281 |
|||
60->7699 |
|||
64->8893 |
|||
96->22039 |
|||
100->24133 |
|||
102->25237 |
|||
108->28697 |
|||
114->32353 |
|||
122->37561 |
|||
124->38921 |
|||
130->43201 |
|||
132->44683 |
|||
146->55837 |
|||
152->61027 |
|||
158->66463 |
|||
162->70241 |
|||
Real: 00:00:00.015 |
|||
</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
{{works with|Factor|0.99 2021-02-05}} |
{{works with|Factor|0.99 2021-02-05}} |