The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
HP49-50G Willan's formulae to find p(n), the n-th prime number
05-18-2024, 10:45 PM (This post was last modified: 05-18-2024 11:25 PM by Gil.)
Post: #1
HP49-50G Willan's formulae to find p(n), the n-th prime number
I tried to put, from Wikipedia, Willan's formulae to find p(n), the n-th prime number, on the HP50G.

Code:

\<< \-> n '1+\GS(ii=1,2^n,FLOOR((n/\GS(j=1,ii,FLOOR(COS(((j-1)!+1)*\pi/j)^2)))^(1/n)))' \->NUM
\>>

For n=1, I get 2, ok
For n=2, I get 3, ok
For n=3, I get 5, ok
For n=4, I get 7, ok
For n=5, I get 33!
For n=6, I get 65!

Could somebody tell me what is wrong in my code above?

NB
However, the following user RPN code works nicely with the loop instructions FOR... NEXT.
Code:

\<< \-> n
  \<< 1 1 2 n ^
    FOR ii 0 1 ii
      FOR j j 1 - ! 1 + j / \pi * COS SQ FLOOR +
      NEXT n SWAP / n INV ^ FLOOR +
    NEXT
  \>>
\>>
Thanks for your help.

Gil
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP49-50G Willan's formulae to find p(n), the n-th prime number - Gil - 05-18-2024 10:45 PM



User(s) browsing this thread: 2 Guest(s)