Talk:Legendre prime counting function: Difference between revisions

 
(2 intermediate revisions by the same user not shown)
Line 56:
 
:: BTW, thanks for "twigging" me on this issue leading to the resolution of both of the problems of the incorrect results and the segmentation faults for higher ranges. --[[User:GordonBGood|GordonBGood]] ([[User talk:GordonBGood|talk]]) 06:37, 11 November 2022 (UTC)
 
::: I've aligned my C example with the changes you've made to the V example and it's now working fine for a trillion numbers and beyond. As the Go and Wren examples were already working, I've just changed a couple of variable names rather than messing with the types.
 
::: It's all making perfect sense now :) --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 09:51, 11 November 2022 (UTC)
 
A minor point but I've just noticed that the V entry (and hence the translations of it) don't deal with the trivial cases n = 3 to 8 inclusive. To solve it without messing with the algorithm I suggest inserting the following as the second line of the ''count_primes_to'' function:
<pre>
if n < u64(9) { return i64((n + 1) / 2) }
</pre> --[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 20:50, 12 November 2022 (UTC)
 
If we do that, we can simplify the first line to:
<pre>
if n < u64(2) { return i64(0) }
</pre>
--[[User:PureFox|PureFox]] ([[User talk:PureFox|talk]]) 21:21, 12 November 2022 (UTC)
9,482

edits