RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
|
07-03-2019, 08:00 PM
(This post was last modified: 07-03-2019 10:38 PM by Gerson W. Barbosa.)
Post: #20
|
|||
|
|||
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
Thank you all for your interest, comments and great contributions!
Here is my solution, as hidden elsewhere in this thread: « { } 1 0 DUP 5 ROLL START 1 OVER START UNROT NEXTPRIME ROT NEXT UNROT + LASTARG NIP ROT 2 + NEXT DROP2 » 73 bytes, 409.2391 seconds for k = 99 Algorithm: input k p := 1 q := 0 for i := 0 to k for j := 1 to q ; notice the loop is executed once, when q = 0 p := nextprime(p) next j print p q := q + 2 next i My initial goal was making it shorter than 100 bytes, as my previous program was 112 bytes longer, not to mention it was significantly slower, so I didn't try to optimize it any further. All of the pure RPN solutions submitted thus far are slightly faster and yet small enough in size, which is great. Author time (s, k=99) CK Size John Keith 402.9453 # 2F5h 83 Claudio L. 403.7325 # 4E5Eh 78 David M. 407.3202 # F924h 75 That's OEIS sequence A122566. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)