HP Forums
(50G) Self Numbers, OEIS A003052 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (50G) Self Numbers, OEIS A003052 (/thread-5923.html)



(50G) Self Numbers, OEIS A003052 - Gerald H - 03-24-2016 10:20 AM

For non-negative integer input the programme returns the smallest Self number greater than the input to the stack.

eg For input

98765432167

the programme returns

98765432176

which is indeed the next Self number.

For more info on self numbers see:

https://oeis.org/A003052

Code:

::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^DupZIsNeg?
    caseSIZEERR
    BINT0
    1LAMBIND
    BEGIN
    Z1_
    FPTR2 ^RADDext
    DUP
    Z2_
    FPTR2 ^ZQUOText
    OVERDUP
    CODE 00025 143174E78FB9760131174143818F858DC7530
    FPTR2 ^#>Z
    Z9_
    FPTR2 ^RMULText
    FPTR2 ^RSUBext
    FPTR2 ^ZNMax
    1PUTLAM
    DUP
    BEGIN
    ::
      Z1_
      FPTR2 ^RSUBext
      DUP
      1GETLAM
      Z<
      case
      ::
        FPTR2 ^DROPZ0
        TRUE
      ;
      DUP
      FPTR2 ^Z>S
      DUP
      BIGDISPROW3
      ZEROSWAP
      DUPLEN$
      ZERO_DO
      DUP
      CAR$
      CHR>#
      BINT48
      #-
      ROT+SWAP
      CDR$
      LOOP
      DROP
      FPTR2 ^#>Z
      OVER
      FPTR2 ^RADDext
      3PICK
      EQUAL
    ;
    UNTIL
    FPTR2 ^QIsZero?
    UNTIL
    ABND
  ;
;