1 LIST 15 AGAIN DROP 7 DO LAST @ I - DUP 1+ 3 MOD 0= 1 ( Large Factorial ) DECIMAL 16 ; 8 I 0= NOT AND IF ASCII , EMIT THEN 2 17 9 F-BUFF C@ 1 U.R 3 FORGET TASK : TASK ; 18 10 LOOP 4 19 11 ; 5 : BYTE-ARRAY CREATE ALLOT ;CODE 20 ,S 12 : FAC 6 DE INC, HL POP, DE HL ADD, HPUSH 13 SETUP 7 3 LIST 14 1+ 1 DO I *BUFF LOOP 8 4000 EQU MAX-DIGITS 1 ( Factorial 3 ) 15 ; 9 MAX-DIGITS BYTE-ARRAY F-BUFF 2 16 : FACS TEXT SETUP 1+ 1 10 VARIABLE LAST ( Last buff element ) 3 : SETUP 1 0 F-BUFF C! 17 DO I *BUFF ." Factorial" I 3 U.R 11 4 0 LAST ! 18 ." = " .FRC CR 12 2 3 THRU 5 ; 19 LOOP 13 6 : .FAC LAST @ 1+ 0 20 ; ;S 14 ;S 15 16 17 Sample run. 18 20 FACS 19 Factorial 1 = 1 Factorial 11 = 39,916,800 20 ;S Factorial 2 = 2 Factorial 12 = 479,001,600 2 LIST Factorial 3 = 6 Factorial 13 = 6,227,020,800 1 ( Factorial 2 ) Factorial 4 = 24 Factorial 14 = 87,178,291,200 2 Factorial 5 = 120 Factorial 15 = 1,307,674,368,000 3 : *BUFF ( Multiplier ) Factorial 6 = 720 Factorial 16 = 20,922,789,888,000 4 0 ( Carry ) LAST @ 1+ 0 Factorial 7 = 5,040 Factorial 17 = 355,687,428,096,000 5 DO OVER I F-BUFF C@ * + Factorial 8 = 40,320 Factorial 18 = 6,402,373,705,728,000 6 10 /MOD SWAP I F-BUFF C! Factorial 9 = 362,880 Factorial 19 = 121,645,100,408,832,000 7 LOOP Factorial 10 = 3,628,800 Factorial 20 = 2,432,902,008,176,640,000 8 ( Extend buffer to accept final carry ) 9 BEGIN ?DUP 10 IF 10 /MOD SWAP >100 FRC .FAC 11 1 LAST +! LAST @ DUP 1+ 93,326,215,443,944,152,681,699,238,856,266,700,490,715,968,264, 12 MAX-DIGITS > 381,621,468,592,963,895,217,599,993,229,915,608,941,463,976, 13 IF ." Out of buffer" QUIT THEN 156,518,286,253,697,920,827,223,758,251,185,210,916,864,000, 14 F-BUFF C! 000,000,000,000,000,000,000