HP Forums

Full Version: (49G) OEIS A000966: n! never ends in this many 0's
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For natural number input N the programme returns the Nth element of the sequence

https://oeis.org/A000966

SIZE 356.5

CKSUM # D0A0h

Code:
«
  « DUPDUP 5 IQUOT
-
    WHILE DUPDUP 0
SWAP
      DO 5 IQUOT
DUP ROT + SWAP DUP
NOT
      UNTIL
      END DROP +
PICK3 <
    REPEAT 1 +
    END NIP
  »
  « DUP 1 <
    IF
    THEN DROP 0
    ELSE 0 SWAP
      WHILE 5 IDIV2
NOT
      REPEAT SWAP 1
+ SWAP
      END DROP
    END
  » → A B
  « DUP A EVAL DUP
B EVAL SWAP DUP 6 *
1 -
    DO SWAP 5 IQUOT
DUP UNROT + OVER
NOT
    UNTIL
    END NIP OVER
    IF
    THEN ROT -1
      DO 1 + SWAP 1
- SWAP OVER A EVAL
B EVAL NOT
      UNTIL
      END NIP +
SWAP -
    ELSE UNROT
DROP2
    END
  »
»
Reference URL's