HP Forums
(49G) Cross Sum of a Roman Number, OEIS A093783 - 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) Cross Sum of a Roman Number, OEIS A093783 (/thread-4677.html)



(49G) Cross Sum of a Roman Number, OEIS A093783 - Gerald H - 09-08-2015 03:37 PM

The programme finds the cross sum of the Roman integer represented by the Arabic input.

eg For input

1984

also known as

MCMLXXXIV

the programme returns

2186 = M+C+M+L+X+X+X+V+I

For more info see

http://oeis.org/A093783

Code:

::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^DupQIsZero?
    caseSIZEERR
    FPTR2 ^Z>S
    Z0_
    SWAP
    DUPLEN$
    ZERO_DO
    DUP
    ISTOP-INDEX
    SUB$1#
    BINT48
    #-
    BINT4
    OVER#=
    OVER
    BINT9
    #=
    OR
    IT
    #2+
    FPTR2 ^#>Z
    Z10_
    INDEX@
    FPTR2 ^RP#
    FPTR2 ^RMULText
    ROT
    FPTR2 ^RADDext
    SWAPLOOP
    DROP
  ;
;