Legendre prime counting function: Difference between revisions
Content added Content deleted
(→{{header|Go}}: Improved 'memoization' version.) |
m (→Non-memoized: Oops, corrected memory usage.) |
||
Line 1,552: | Line 1,552: | ||
Inspired by the non-memoized Nim version. |
Inspired by the non-memoized Nim version. |
||
The memoized version requires a cache of around 6.5 million |
The memoized version requires a cache of around 6.5 million map entries, which at 8 bytes each (all numbers are 64 bit floats in Wren) for both the key and the value, equates in round figures to memory usage of 104 MB on top of that needed for the prime sieve. The following version strips out memoization and, whilst somewhat slower at 5.4 seconds, may be preferred in a constrained memory environment. |
||
<syntaxhighlight lang="ecmascript">import "./math" for Int |
<syntaxhighlight lang="ecmascript">import "./math" for Int |
||