Post Reply 
RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
07-03-2019, 10:33 PM
Post: #21
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
(07-03-2019 08:00 PM)Gerson W. Barbosa Wrote:  Thank you all for your interest, comments and great contributions!

Wait, wait!

I have 2 more... neither will be winners of anything, just different approaches to those presented before.

The first one is literal translation of the algorithm you just revealed, except 'q' counts with step 1 and NEXTPRIME is done in pairs:

    SWAP 1 + SWAP 

The second one is inspired by the OEIS website, where it shows the highest number is ithPrime(k^2+k+1), so we can just do NEXTPRIME k^2+k+1 times, but keeping (with DUP) just the ones we are interested in, that have an index 'i' of the form 'i^2+i+1':

  0 → 
    i « 1 + DUPDUP *
    + 2 1 ROT
    FOR 'K'
      IF i DUPDUP * +
      1 + K == THEN
        DUP 1 'i' STO+
    DROP i →LIST 
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g) - Claudio L. - 07-03-2019 10:33 PM

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