HP Forums
(49G) OEIS A084545: Counting Base 5 without Zero - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (49G) OEIS A084545: Counting Base 5 without Zero (/thread-8947.html)



(49G) OEIS A084545: Counting Base 5 without Zero - Gerald H - 08-31-2017 03:07 PM

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



RE: (49G) OEIS A084545: Counting Base 5 without Zero - Gerald H - 09-01-2017 03:57 PM

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
  ;
;



RE: (49G) OEIS A084545: Counting Base 5 without Zero - Joe Horn - 09-01-2017 11:09 PM

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



RE: (49G) OEIS A084545: Counting Base 5 without Zero - Gerald H - 09-03-2017 02:43 PM

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
  ;
;



RE: (49G) OEIS A084545: Counting Base 5 without Zero - Eric Rechlin - 09-04-2017 07:16 PM

With that last version, I get 111.5 bytes and #DF96h, and it just hangs when I run it.


RE: (49G) OEIS A084545: Counting Base 5 without Zero - Gerald H - 09-04-2017 08:22 PM

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?


RE: (49G) OEIS A084545: Counting Base 5 without Zero - Joe Horn - 09-04-2017 09:40 PM

(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).


RE: (49G) OEIS A084545: Counting Base 5 without Zero - Eric Rechlin - 09-05-2017 01:08 AM

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-8939-post-78579.html#pid78579