Prime number finder HP11C?
|
06-19-2016, 01:14 PM
Post: #16
|
|||
|
|||
RE: Prime number finder HP11C?
Dear Don,
'the whole thing' is in fact quite short: 0xP+L(K:1)x0+PRIME=(L(C:1)-C+SIGMA(D:3:SQRT(P)+1:2:IF(FP(P/D)<>0:1+L(C)x0+L(K:0)x0)))xK+PxK+L(P+2)x0 (SIGMA means the Greek capital, of course) Use: type starting number (must be odd), press P outcome is 0 if P is not a prime, otherwise P is given. Press PRIM to continue search. (new P is two higher than original) This equation has evolved and is not optimized for shortness. Also, I don't remember why C and K are output. The advanced guide for the 19B and 28C/S gives the way to suppress them (quite easy). The main algorithm is standard for the solver. It seems quite rough, as the search for a divisor is always continued up to the square root, but that is the consequence of the fact that you cannot branch out of a sum. Nevertheless, the search is quite quick, as I mentioned earlier. best regards, Jaap. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)