(50g) OEIS A008904: Last Non-Zero Digit of Factorial

+- HP Forums (http://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (50g) OEIS A008904: Last Non-Zero Digit of Factorial (/thread-9022.html)



(50g) OEIS A008904: Last Non-Zero Digit of Factorial - Gerald H - 09-23-2017 10:17 AM

For input N , a natural number, the programme returns the Nth element in the series

https://oeis.org/A008904

NB This series does NOT become periodic.

Size: 130.5

CkSum: # 7672h

Code:
::
  CK1&Dispatch
  # FF
  ::
    DUP
    Z2_
    Z<
    casedrop
    Z1_
    Z2_
    ZEROZERO
    4ROLL
    BEGIN
    Z5_
    FPTR2 ^ZDIVext
    FPTR2 ^Z>#
    DUP
    4ROLL
    DUP#1+
    5UNROLL
    #*
    SWAP
    BINT2
    #/
    SWAP
    #0=ITE
    #+
    DROP
    4ROLL
    #+
    UNROTDUP
    Z0_
    EQUAL
    UNTIL
    2DROP
    BINT4
    #/
    DROP
    FPTR2 ^RP#
    DUP
    Z1_
    EQUALNOT
    ?SEMI
    DROP
    Z6_
  ;
;