Post Reply 
Programming puzzle: Longest list of regular numbers?
04-17-2017, 06:50 PM (This post was last modified: 04-17-2017 07:51 PM by Han.)
Post: #19
RE: Programming puzzle: Longest list of regular numbers?
I used the HP48 and solved #2 in 3 minutes 24 seconds. I think it could probably be improved a slight bit with pure stack storage.

Also, the 1429th number is actually 603979776 and not 604661760 (this is the 1430th number). I think e_emil is off by one. Place index on the stack and run the program below:

EDIT: Fixed a few typos (I typed this out by hand and did some sloppy copy/paste/edit).

Code:

\<<
  2 2 1 2 3 5 \-> n i j k x2 x3 x5
  \<<
    1 2 n
    IF DUP2 > THEN DROP2 ELSE

      FOR l
        x2 x3 MIN x5 MIN DUP l 1 + ROLLD
        IF x2 OVER == THEN
          1 'i' STO+ i PICK 2 * 'x2' STO
        END
        IF x3 OVER == THEN
          1 'j' STO+ j PICK 3 * 'x3' STO
        END
        IF x5 == THEN
          1 'k' STO+ k PICK 5 * 'x5' STO
        END
      NEXT

    END
  \>>
\>>

Output is basically all the terms in the sequence, with the n-th term placed on the n-th level of the stack.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzle: Longest list of regular numbers? - Han - 04-17-2017 06:50 PM



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