I ported this program from Altair 680 VTL-2 code. It calculates factorials beginning with 1 and reaches 328 before it halts with ">32767" error. Still, the factorial of 328 is over 680 digits long! I need to find a way to keep the array elements below the 32767 limit. Apparently VTL-2 did not represent negative numbers so the array elements could be as high as 65535. If anybody has any ideas, please let me know.

For those of you who don't remember, a factorial is a number multiplied by lesser numbers until zero is reached. For example, the factorial of 5 (expressed as 5!) would be 5*4*3*2*1=120 or 6!=6*5*4*3*2*1=720 and so on....

Here's the listing:

1 REM CALCULATION OF FACTORIALS

2 REM PORTED FROM ALTAIR VTL-2

3 REM BY MIKE PENZO DEC 9, 2007

4 DIM A(500)

5 FOR I=1 TO 500

6 LET A(I)=0

8 NEXT I

10 LET P=1

20 LET L=2

30 LET A(1)=1

40 LET I=2

50 LET A(I)=0

60 LET I=I+1

70 IF L>I THEN 50

80 PRINT

90 PRINT

100 PRINT P;

110 PRINT "!="

120 REM

130 LET I=L+1

140 LET I=I-1

150 IF A(I)=0 THEN 140

160 PRINT A(I);

170 LET I=I-1

180 IF I=0 THEN 220

190 LET V=A(I)/10

200 PRINT V;

205 PRINT A(I)-(V*10);

210 GOTO 170

220 LET P=P+1

230 LET I=1

240 LET C=0

250 LET X=A(I)

260 LET A(I)=P*X

270 IF A(I)<X THEN 320

280 LET A(I)=A(I)+C

290 LET C=A(I)/100

300 LET Q=C

305 LET A(I)=A(I)-(Q*100)

310 LET I=I+1

320 IF L>I THEN 250

330 IF C=0 THEN 80

340 LET L=L+1

350 REM

360 LET A(I)=C

370 GOTO 290

380 END