formula for nth prime (!)

48 views
Skip to first unread message

John Hanna

unread,
Nov 17, 2023, 7:07:59 AM11/17/23
to tins...@googlegroups.com

Who knew this all this time and didn’t tell me?

 

The article:

https://www.scientificamerican.com/article/simple-formula-makes-prime-numbers-easy-but-a-million-dollar-mystery-remains/

 

Having trouble with the Python code in the attached: it works up to p(6). At p(7) the program breaks because the int from fact(7) is too large to convert to a float (it returns inf).

 

Workaround?

 

Killing time,

   John

 

 

Regards,

     John

 

image002.jpg
prime formula.tns

Karlheinz Haas

unread,
Nov 17, 2023, 11:45:26 AM11/17/23
to tinspire
I guess we all just thought if anybody knows about this, it would be John H.  :-)

Karlheinz

eagl...@duetsoftware.ca

unread,
Nov 17, 2023, 6:28:51 PM11/17/23
to tins...@googlegroups.com
You could try making a library that implements something like Java’s BigInteger class.
Eric

On Nov 17, 2023, at 4:08 AM, John Hanna <johne...@gmail.com> wrote:



Who knew this all this time and didn’t tell me?

<image002.jpg>

 

The article:

https://www.scientificamerican.com/article/simple-formula-makes-prime-numbers-easy-but-a-million-dollar-mystery-remains/

 

Having trouble with the Python code in the attached: it works up to p(6). At p(7) the program breaks because the int from fact(7) is too large to convert to a float (it returns inf).

 

Workaround?

 

Killing time,

   John

 

 

Regards,

     John

 

--
--
To post to this group, send email to tins...@googlegroups.com
To unsubscribe send email to tinspire+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com.au/group/tinspire?hl=en-GB?hl=en-GB
The tns documents shared by group members are archived at
https://sites.google.com/site/tinspiregroup/classroom-news/welcome-abouttime

---
You received this message because you are subscribed to the Google Groups "tinspire" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tinspire+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tinspire/014001da194e%24bd7732a0%24386597e0%24%40gmail.com.
<prime formula.tns>

John Hanna

unread,
Nov 17, 2023, 7:27:59 PM11/17/23
to tins...@googlegroups.com

I need a bigfloat!

 

And it’s not 7!, it’s 171! (and higher)  that appears when computing p(7).

 

 

Regards,

     John

image001.png
Reply all
Reply to author
Forward
0 new messages