Legendre prime counting function: Difference between revisions
Content deleted Content added
GordonBGood (talk | contribs) m put Java contribution in alphabetic order... |
GordonBGood (talk | contribs) m →Non Memoized Haskell Versions: Haskell: improve comments... |
||
Line 1,370:
'''The Non-Recursive Partial Sieving Algorithm'''
Just substitute the following Haskell code for the `countPrimes` function above to enjoy the further gain in speed; this version may appear to be recursive to those unfamiliar with Functional Programming (FP) implementations but FP generally turns all function recursions in tail-call position (which all of these are) into the same compiled code as a simple loop in other languages:
<syntaxhighlight lang="haskell">
if n < 3 then (if n < 2 then 0 else 1) else
let
|