Post Reply 
2023 RPN HHC Programming Contest
10-16-2023, 03:37 AM
Post: #61
RE: 2023 RPN HHC Programming Contest
(10-16-2023 02:31 AM)Allen Wrote:  indeed.. the others are less practical as they require too many terms for a short program!

Meanwhile, by using a(n) = n² + n - 1, for n = 6, 8 instead, I was able to save one more byte:

Code:

 01 LBL "HHC"
 02 PI
 03 X^2
 04 INT
 05 XEQ 00
 06 LASTX
 07 LBL 00
 08 DSE X
 09 X^2
 10 LASTX
 11 DSE X
 12 +
 13 END

13 steps, 25 bytes.

Or, back to a(n) = n² - n - 1, for n = 7, 9 and assuming a positive number in stack register X, one more step can be saved:

Code:

 01 LBL "HHC"
 02 SIGN
 03 10^X
 04 XEQ 00
 05 LASTX
 06 LBL 00
 07 DSE X
 08 ENTER
 09 DSE X
 10 *
 11 DSE X
 12 END

12 steps, 25 bytes.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
2023 RPN HHC Programming Contest - Gene - 10-07-2023, 01:00 PM
RE: 2023 RPN HHC Programming Contest - Gerson W. Barbosa - 10-16-2023 03:37 AM



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