Post Reply 
Find number property and write RPL program (HP-49G,G+, HP 50g)
09-24-2014, 07:16 PM
Post: #14
RE: Find number property and write RPL program (HP-49G,G+, HP 50g)
Okay, here I am with my RPL solution.

Program 'SGPrimes':
Code:
%%HP: T(3)A(R)F(.);
\<< \-> n
  \<< { } 0 2
    WHILE OVER n <
    REPEAT DUP
      IF ISPRIME?
      THEN DUP 2 * 1 +
        IF ISPRIME?
        THEN SWAP 1 + SWAP ROT OVER + UNROT
        END
      END NEXTPRIME
    END DROP2
  \>>
\>>

Usage examples:
Code:

 5 --> { 2 3 5 11 23 }
10 --> { 2 3 5 11 23 29 41 53 83 89 }
20 --> { 2 3 5 11 23 29 41 53 83 89 112 131 173 179 191 233 239 251 281 293 }
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Find number property and write RPL program (HP-49G,G+, HP 50g) - Thomas Ritschel - 09-24-2014 07:16 PM



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