Post Reply 
(49G) OEIS A084545: Counting Base 5 without Zero
08-31-2017, 03:07 PM
Post: #1
(49G) OEIS A084545: Counting Base 5 without Zero
For integer input N the programme returns the Nth element of the sequence

https://oeis.org/A084545

NB The description below uses the expression

eg Z4_

for ZINT 4.

The two are however NOT the same, Z4_ having 2.5 Bytes & ZINT 4 having 6 Bytes.

The size & check sum below are for the version as printed.

Code:
::
  CK1&Dispatch
  # FF
  ::
    Z4_
    FPTR2 ^RMULText
    Z1_
    FPTR2 ^RADDext
    DUP
    FPTR2 ^Z>R
    %LN
    %5
    %LN
    %/
    %FLOOR
    %IP
    COERCESWAP
    Z5_
    3PICK
    FPTR2 ^RP#
    FPTR2 ^RSUBext
    NULL$
    ROT
    ZERO_DO
    OVER
    Z4_
    Z5_
    INDEX@
    FPTR2 ^RP#
    FPTR2 ^RMULText
    FPTR2 ^ZQUOText
    Z5_
    FPTR2 ^ZMod
    Z1_
    FPTR2 ^RADDext
    FPTR2 ^Z>S
    SWAP&$
    LOOP
    SWAPDROP
    FPTR2 ^S>Z
  ;
;

CKSUM # ADFFh

SIZE 149.5
Find all posts by this user
Quote this message in a reply
09-01-2017, 03:57 PM
Post: #2
RE: (49G) OEIS A084545: Counting Base 5 without Zero
A faster version of the programme:

Code:
::
  CK1&Dispatch
  # FF
  ::
    Z1_
    SWAP
    Z4_
    FPTR2 ^RMULText
    Z1_
    FPTR2 ^RADDext
    DUP
    FPTR2 ^Z>R
    %LN
    %5
    %LN
    %/
    %FLOOR
    %IP
    COERCESWAP
    Z5_
    3PICK
    FPTR2 ^RP#
    FPTR2 ^RSUBext
    NULL$
    ROT
    ZERO_DO
    OVER
    4ROLL
    DUP
    Z5_
    FPTR2 ^RMULText
    5UNROLL
    Z4_
    FPTR2 ^RMULText
    FPTR2 ^ZQUOText
    Z5_
    FPTR2 ^ZMod
    Z1_
    FPTR2 ^RADDext
    FPTR2 ^Z>S
    SWAP&$
    LOOP
    ROTROT2DROP
    FPTR2 ^S>Z
  ;
;
Find all posts by this user
Quote this message in a reply
09-01-2017, 11:09 PM
Post: #3
RE: (49G) OEIS A084545: Counting Base 5 without Zero
If you use the standard HP extable library and 50g's built-in assembler, you can use Gerald's source code if you add the following lines to the very beginning:

Code:
EQU Z1_ 273B6
EQU Z4_ 273DA
EQU Z5_ 273E6

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
09-03-2017, 02:43 PM
Post: #4
RE: (49G) OEIS A084545: Counting Base 5 without Zero
But this programme is much faster & smaller:

Size: 110.5

CkSum: # 6A43h

Code:
::
  CK1&Dispatch
  # FF
  ::
    NULL$SWAP
    BEGIN
    ZINT 5
    FPTR2 ^ZDIVext
    DUP
    ZINT 0
    EQUAL
    IT
    ::
      DROP
      ZINT 5
      SWAP
      ZINT 1
      FPTR2 ^RSUBext
      SWAP
    ;
    FPTR2 ^Z>S
    ROT
    &$SWAP
    DUP
    ZINT 0
    EQUAL
    UNTIL
    DROP
    FPTR2 ^S>Z
  ;
;
Find all posts by this user
Quote this message in a reply
09-04-2017, 07:16 PM
Post: #5
RE: (49G) OEIS A084545: Counting Base 5 without Zero
With that last version, I get 111.5 bytes and #DF96h, and it just hangs when I run it.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-04-2017, 08:22 PM (This post was last modified: 09-04-2017 08:23 PM by Gerald H.)
Post: #6
RE: (49G) OEIS A084545: Counting Base 5 without Zero
I have copied the published programme & compiled on 50g, programme works correctly & size 110.5 & Cksum 6A43 as published above.

Has anyone besides Eric had problems?
Find all posts by this user
Quote this message in a reply
09-04-2017, 09:40 PM (This post was last modified: 09-04-2017 09:42 PM by Joe Horn.)
Post: #7
RE: (49G) OEIS A084545: Counting Base 5 without Zero
(09-04-2017 08:22 PM)Gerald H Wrote:  I have copied the published programme & compiled on 50g, programme works correctly & size 110.5 & Cksum 6A43 as published above.

Has anyone besides Eric had problems?

It runs fine on mine, and yields the size & checksum you cited. (It fails with inputs < -4 but that might be expected).

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
09-05-2017, 01:08 AM
Post: #8
RE: (49G) OEIS A084545: Counting Base 5 without Zero
I take back what I said. This is a bug in Jazz. See my explanation on the other thread:

http://www.hpmuseum.org/forum/thread-893...l#pid78579
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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