Post Reply 
Challenge: First Digit of Factorial Programme
12-05-2017, 08:11 AM (This post was last modified: 12-05-2017 09:46 AM by Gerald H.)
Post: #1
Challenge: First Digit of Factorial Programme
The challenge is to produce a programme that for natural number input N returns the first, ie leftmost, digit of N! on the 50g.

The programme below uses the formula here

http://mathworld.wolfram.com/StirlingsAp...ation.html

& gives correct answers for input 0 to 5,362.

The OEIS reference is here

Edit: Was wrong link.

https://oeis.org/A008905

Speed is the secondary consideration & accuracy the first.

I don't expect my programme to be bettered but would be very pleased to be proven wrong.

Size: 76.

CkSum: # 86A4h

Code:
::
  CK1&Dispatch
  BINT1
  ::
    %>%%
    DUPDUP
    %%+
    %%3
    %%1/
    %%+
    %%PI
    %%*
    %%SQRT
    OVERDUP
    %%^
    ROT
    %%EXP
    %%/
    %%*
    %%.5
    %%+
    %%INT
    DO>STR
    BINT1
    BINT1
    SUB$
    FPTR2 ^S>Z
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)