Ulam numbers: Difference between revisions

m
No edit summary
m (→‎{{header|Wren}}: Minor tidy)
Line 1,688:
===Version 1===
{{libheader|Wren-set}}
<syntaxhighlight lang="ecmascriptwren">import "./set" for Set
 
var ulam = Fn.new() { |n|
Line 1,732:
{{libheader|Wren-fmt}}
The above version is reasonably efficient and runs in about 21.6 seconds on my machine (Intel Core i7-8565U). The following version, which builds up a sieve as it goes along, is more than 3 times faster.
<syntaxhighlight lang="ecmascriptwren">import "./seq" for Lst
import "./fmt" for Fmt
 
var ulam = Fn.new { |n|
Line 1,775:
 
The only downside with this version is that you need to know how much memory to allocate in advance.
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
 
var ulam = Fn.new { |n|
9,485

edits