Talk:Extensible prime generator: Difference between revisions

(comment on "off by one"...)
Line 14:
::: That just confirms that the correct value is 104,729. The Rust code was wrong; the author forgot that enumerations are zero based in Rust, so one has to ask for item number 9,999 to get the 10,000th prime. I've corrected Rust.
::: It appears that Seed had a slightly different logic error: it iterated and discarded the primes until the 10,000th one, then printed the next one. I've fixed that, too.--[[User:GordonBGood|GordonBGood]] ([[User talk:GordonBGood|talk]]) 23:25, 6 January 2019 (UTC)
 
== analytic formula for primes ==
 
Haskell's analytic formula for primes seems to essentially be a mechanism for packing the sequence of prime numbers into a number.
 
The expression is basically int(A*frac(B*C)) where values of A come from the sequence (6, 20, 42, 72, 110, 156, 210, 272, 342, 420, ...) and values of B come from the sequence (1, 6, 120, 5040, 362880, 39916800, 6227020800, 1307674368000, 355687428096000, 121645100408832000, ...)
 
The ratio between adjacent values of B (6, 20, 42, 72, 110, 156, 210, 272, 342, ...) grows faster than prime numbers grow, so conceptually speaking there's plenty of room here for encoding the prime numbers. (C=0.359344964622775339841352348439200241924659634 would encode the first 18 primes.)
 
That said... this *is* cute. But it also has a bit of a deus ex machina flavor. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 03:22, 2 July 2022 (UTC)
6,951

edits