Jump to content

Legendre prime counting function: Difference between revisions

m
→‎Non-memoized: Oops, corrected memory usage.
(→‎{{header|Go}}: Improved 'memoization' version.)
m (→‎Non-memoized: Oops, corrected memory usage.)
Line 1,552:
Inspired by the non-memoized Nim version.
 
The memoized version requires a cache of around 6.5 million numbersmap 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 52104 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
 
9,483

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.