Hi,

This is not a silly question, but an interessant computing challenge on both HP28 and HP48 advanced calculators.

Fortunately, and without any "Erable" add-in or any newer CAS feature, any HP-48 are able to compute and display any digits of the n! factorial by using a quite easy and not so elaborated dFACT program which was compose by myself in 1989 for the same purpose on a HP-28S.

For easy reading and printing dFACT returns all digits of the n! factorial into the stack by ten-digit numbers.

Printing will be easy with print stack command PRST and storing all this stuff in a list by using DEPTH ->LIST sequence.

« -> n @ input n from stack

« n ->STR 33 CHR + 61 CHR + @ put string "n!=" on top of stack

2 ‘d’ STO @ initialize dimension d

1 @ initialize stack with 1!

1 n FOR k @ main loop n!=1*2* ... *k*...*n

0 @ zero carry

2 d FOR p @ for each of the d ten-digit-number

p ROLL @ p-th ten-digit from stack

k * @ multiply by k

+ @ add carry

1E10 MOD @ ten-digit rest

LAST / IP @ set and round carry

SWAP p ROLLD @ roll ten-digit back in stack

NEXT

IF DUP @ test last carry

THEN @ if any

d ROLLD @ add one more ten-digit in stack

‘d’ 1 STO+ @ increase d value

ELSE

DROP @ erase null carry

END

NEXT

»

»

‘dFACT’ STO

Examples:

0 dFACT -->2: "0!="

1: 1
1 dFACT -->2: "1!="

1: 1

5 dFACT -->2: "5!="

1: 120

13 dFACT -->2: "13!="

1: 6227020800

14 dFACT -->3: "14!="

2: 8

1: 7178291200

17 dFACT -->3: "17!="

2: 35568

1: 74280960000

Upto ther nothing special and results are equivalent to built-in FACT instruction.

23 dFACT -->4: "23!="

3: 258

2: 5201673888

1: 4976640000

100 dFACT --->17: "100!="

16: 93326215

15: 4439441526

14: 8169923885

13: 6266700490

12: 7159682643

11: 8162146859

10: 2963895217

9: 5999932299

8: 1560894146

7: 3976156518

6: 2862536979

5: 2082722375

4: 8251185210

3: 9168640000

2: 0

1: 0

Main inconvenient is exponential computation time, on HP28C/S :

10! Need only 2"00, 50! nearly 11"48, 100! is about 44"94, 150! as long as 1’45"05, . . . , 400! In nearly 16’30" and at least 446! in 21 very long minutes.

Source (in Fench only): http://www.silicium.org/forum/viewtopic.php?f=46&t=20757&start=45