100 CLS
110 A$=STRING$(80,205)
120 PRINT A$
130 PRINT TAB(18)"20 COMPLEX MATHEMATICAL FUNCTIONS  3010-A.BAS "
140 COLOR 23,0,0
150 PRINT :PRINT :PRINT TAB(38)"IPCO"
160 COLOR 7,0,0
170 PRINT :PRINT :PRINT TAB(29)"INTERNATIONAL PC OWNERS"
180 PRINT :PRINT :PRINT TAB(17)"p.o. box 10426, pittsburgh, pennsylvania 15234"
190 PRINT A$
200 PRINT :PRINT :PRINT :PRINT :PRINT
210 PRINT TAB(28)"PRESS ANY KEY TO CONTINUE"
220 A$=INKEY$:IF A$="" THEN 220
230 CLS
240 PRINT CHR$(12):KEY OFF
250 LOCATE 6,30:PRINT"THIS PROGRAM COMPUTES"
260 LOCATE 9,23:COLOR 15:PRINT"20 COMPLEX MATHEMATICAL FUNCTIONS"
270 LOCATE 12,27:COLOR 7
280 LOCATE 14,40:PRINT"By"
290 LOCATE 16,35:PRINT"Tony Bagshaw"
300 FOR I=1 TO 1500:NEXT I:PRINT CHR$(12):COLOR 7,0
310 LOCATE  2,3:PRINT" 1. Arithmetic mean."
320 LOCATE  3,3:PRINT" 2. Arithmetic progression."
330 LOCATE  4,3:PRINT" 3. Harmonic mean."
340 LOCATE  5,3:PRINT" 4. Harmonic numbers."
350 LOCATE  6,3:PRINT" 5. Harmonic progression."
360 LOCATE  7,3:PRINT" 6. Geometric mean."
370 LOCATE  8,3:PRINT" 7. Geometric progression."
380 LOCATE  9,3:PRINT" 8. Permutations and combinations."
390 LOCATE 10,3:PRINT" 9. Generalized mean."
400 LOCATE 11,3:PRINT"10. Mean, Standard Deviation, etc."
410 LOCATE 12,3:PRINT"11. Interactive growth pattern."
420 LOCATE 13,3:PRINT"12. Straight line depreciation."
430 LOCATE 14,3:PRINT"13. Logarithms of any base."
440 LOCATE 15,3:PRINT"14. Linear interpolation."
450 LOCATE 16,3:PRINT"15. Prime tester."
460 LOCATE 17,3:PRINT"16. Annular sections."
470 LOCATE 18,3:PRINT"17. Chi-Square evaluation."
480 LOCATE 19,3:PRINT"18. Factorials."
490 LOCATE 20,3:PRINT"19. Fibonacci numbers."
500 LOCATE 21,3:PRINT"20. Gamma functions with factorial."
510 GOSUB 4240
520 PRINT CHR$(7):LOCATE 24,26:COLOR 31:INPUT" KINDLY ENTER YOUR CHOICE ";A$
530 A=VAL(A$):COLOR 7:GOTO 4060
540 GOSUB 4070
550 X=0:N=0
560 LOCATE 2,32:PRINT" THE ARITHMETIC MEAN"
570 LOCATE 6,30:COLOR 1:INPUT"ENTER SAMPLING NUMBER";W
580 N=N+1:X=X+W:A=X/N
590 LOCATE 9,27:COLOR 0,7:PRINT"N...........................";N
600 LOCATE 13,27:COLOR 0,7:PRINT"SAMPLE......................";W
610 LOCATE 17,27:COLOR 0,7:PRINT"CURRENT MEAN................";A
620 COLOR 7
630 GOSUB 4090
640 GOTO 560
650 GOSUB 4070
660 LOCATE 2,10:PRINT" THE HARMONIC MEAN"
670 Z=0:N=0:B=6
680 LOCATE 23,28:COLOR 16,7:PRINT" ENTER YOUR SAMPLE NUMBER "
690 LOCATE 23,55:COLOR 7:INPUT"* Zero to quit";X
700 S$=STRING$(79,CHR$(32)):LOCATE 23,1:PRINT S$
710 IF X=0 THEN GOTO 810
720 N=N+1:Z=Z+(1/X):H=N/Z
730 IF N > 1 THEN B=B+1:GOTO 770
740 LOCATE 5,5:PRINT"N"
750 LOCATE 5,10:PRINT"SAMPLE"
760 LOCATE 5,22:PRINT"CURRENT MEAN"
770 IF B=23 THEN LOCATE 24:PRINT
780 IF B >= 23 THEN B=22
790 LOCATE B:COLOR 15:PRINT TAB(4);N;TAB(10);X;TAB(23);H:COLOR 7
800 GOTO 680
810 GOSUB 4090
820 GOTO 660
830 GOSUB 4070
840 LOCATE 5,9:COLOR 1:PRINT"ARITHMETIC PROGRESSION":COLOR 7
850 LOCATE 5,34:PRINT"   FORMULA - A,A+D,A+2D,...A+((N-1)D)"
860 LOCATE 7,5:PRINT"First term =";:INPUT A
870 LOCATE 9,5:PRINT"Common difference =";:INPUT D
880 LOCATE 11,5:PRINT"Number of terms = ";:INPUT N
890 LOCATE 13,5:PRINT"Type in your selection":H=9
900 LOCATE 15,9:PRINT"-1- TABULATION"
910 LOCATE 17,9:PRINT"-2- TOTAL  SUM"
920 LOCATE 19,9:INPUT"Which would you like";C$
930 IF C$="2" THEN LOCATE 17,24:COLOR 15:PRINT CHR$(174):GOTO 970
940 LOCATE 15,24:COLOR 15:PRINT CHR$(174):COLOR 7
950 LOCATE 7,47:PRINT"ARITHMETIC PROGRESSION"
960 LOCATE 9,45:COLOR 9:PRINT "TERM NUMBER":LOCATE 9,60:PRINT"TERM VALUE"
970 COLOR 7:J=0:Z=0:FOR I=0 TO N-1:K=I+1:L=A+(I*D):J=J+L:Z=Z+1:X=9+Z:H=H+1
980 IF C$="1" THEN 1010
990 GOTO 1030
1000 IF X=>25 THEN X=25
1010 IF H>23 THEN H=23:PRINT
1020 LOCATE H,49:PRINT K:LOCATE H,63:PRINT L
1030 NEXT I:PRINT
1040 LOCATE 21,9:PRINT"SUM = ";J
1050 REM LOCATE 21,5:PRINT"WOULD YOU LIKE ANOTHER TRY";:INPUT B$:IF B$="Y" THEN 3218
1060 REM IF B$="N" THEN GOSUB 61000
1070 PRINT:GOSUB 4090:PRINT CHR$(12):GOTO 860
1080 GOSUB 4070:COLOR 9
1090 LOCATE 1,8:PRINT"HARMONIC NUMBERS":COLOR 7
1100 LOCATE 1,35:PRINT"FORMULA - 1,1+1/2,1+1/2+1/3,1+1/2+1/3+1/4,...."
1110 LOCATE 3,31:INPUT"MAXIMUM TERM NUMBER";N
1120 K=0:D=0:J=0:T=1:L=5
1130 FOR I=1 TO N:K=I:C=1/K:D=D+C:J=J+1
1140 IF J >= 2 THEN GOTO 1160
1150 LOCATE L,T:PRINT"TERM NUMBER:-";K:LOCATE L+1,1:T=13:GOTO 1190
1160 IF L=>23 THEN L=23
1170 T=T+11:LOCATE L,T:PRINT K:LOCATE L,T         'move 14 spaces to the right.
1180 IF J >= 2 THEN GOTO 1200
1190 COLOR 15:PRINT"TERM  VALUE:-";D:COLOR 7:GOTO 1210
1200 L=L+1:LOCATE L,T:COLOR 15:PRINT D:COLOR 7:L=L-1   '14 spaces to the right.
1210 IF J = 6 THEN L=L+3:J=0:T=1:GOTO 1220        '# was 4 & move down 2 lines.
1220 IF L>21 THEN L=20:PRINT:PRINT:PRINT:PRINT:PRINT
1230 NEXT I
1240 PRINT:PRINT
1250 GOSUB 4090
1260 GOTO 1080
1270 GOSUB 4070
1280 PRINT TAB(28)"A SERIES OF HARMONIC PROGRESSIONS":PRINT:PRINT
1290 INPUT"VALUE OF A =";A:PRINT
1300 INPUT"VALUE OF B =";B:PRINT
1310 INPUT"DIFFERENCE =";D:PRINT
1320 INPUT"NUMBER OF TERMS =";N:PRINT
1330 INPUT"FOR TABLE TYPE 1, IF NOT TYPE 0";C
1340 IF C=1 THEN 1360
1350 GOTO 1380
1360 PRINT"HARMONIC PROGRESSION"
1370 PRINT"TERM NUMBER","TERM VALUE":PRINT
1380 J=0:FOR I=0 TO N-1:K=I+1:L=A/(B+(I*D)):J=J+L
1390 IF C=1 THEN 1410
1400 GOTO 1420
1410 PRINT K,L
1420 NEXT I
1430 PRINT TAB(40)"SUM =";J:PRINT
1440 GOSUB 4090:PRINT:GOTO 1290
1450 GOSUB 4070
1460 PRINT TAB(33)" THE GEOMETRIC MEAN"
1470 PRINT:PRINT
1480 Y=1:N=0
1490 INPUT"SAMPLE NUMBER (Zero to Quit) =";W
1500 IF W=0 THEN 1540
1510 N=N+1:Y=Y*W:G=Y^(1/N)
1520 PRINT"NUMBER OF SAMPLES =";N,"CURRENT SAMPLE =";W,"CURRENT MEAN =";G
1530 GOTO 1490:PRINT
1540 GOSUB 4090:PRINT:GOTO 1480
1550 GOSUB 4070
1560 PRINT TAB(15)"THE VALUES AND THEIR SUMS OF A GEOMETRIC PROGRESSION":PRINT
1570 PRINT TAB(30)"FORMULA - A,AR,AR^....,AR^n-1"
1580 PRINT:PRINT
1590 INPUT"FIRST TERM =";A
1600 INPUT"RATIO OF TERMS =";R
1610 INPUT"NUMBER OF TERMS =";N:PRINT
1620 INPUT"                   FOR TABLE TYPE 1, IF NOT TYPE 0";C:PRINT
1630 IF C=1 THEN 1650
1640 GOTO 1670
1650 PRINT"GEOMETRIC PROGRESSION"
1660 PRINT"TERM NUMBER","TERM VALUE"
1670 J=0:FOR I=0 TO N-1
1680 K=I+1:L=A*(R^I):J=J+L
1690 IF C=0 THEN 1710
1700 PRINT K,L
1710 NEXT I
1720 PRINT TAB(40)"SUM =";J:PRINT
1730 GOSUB 4090:PRINT:GOTO 1590
1740 GOSUB 4070
1750 PRINT TAB(27)"PERMUTATIONS AND COMBINATIONS":PRINT
1760 PRINT TAB(10)"WHERE N = NUMBER OF ITEMS & R = SIZE OF GROUP SELECTED"
1770 PRINT:PRINT
1780 INPUT"ENTER N,R";N,R
1790 IF NN THEN 3080
3060 T=(I*2)+1
3070 GOTO 3020
3080 PRINT N;"  IS A PRIME NUMBER"
3090 PRINT:PRINT:GOTO 2990
3100 PRINT N;"  IS NOT A PRIME NUMBER ";T;"  IS THE SMALLEST FACTOR"
3110 PRINT:GOTO 2990
3120 GOSUB 4090:PRINT:GOTO 2990
3130 GOSUB 4070
3140 PRINT TAB(16)"THE VARIOUS PARAMETERS CONNECTED WITH AN ANNULAR SECTION"
3150 PRINT:INPUT"INSIDE DIAMETER (D1)  =";D1:PRINT
3160 INPUT"OUTSIDE DIAMETER (D2)  =";D2:PRINT
3170 P=3.14159
3180 I=(P*((D2^4)-(D1^4)))/64:J=I*2
3190 A=(P*((D2^2)-(D1^2)))/4
3200 PRINT"MOMENT OF INERTIA = ";I:PRINT
3210 PRINT"POLAR MOMENT OF INERTIA = ";J:PRINT
3220 PRINT"AREA OF SECTION = ";A:PRINT
3230 GOSUB 4090:PRINT:GOTO 3150
3240 GOSUB 4070
3250 PRINT"CHI-SQUARE EVALUATION ON THE 'OBSERVED' TO 'EXPECTED' FREQUENCIES"
3260 PRINT"(To terminate the evaluation enter a 0 for last expected frequency.)"
3270 PRINT
3280 CLEAR
3290 J=0
3300 INPUT"OBSERVED FREQUENCIES ";D:PRINT
3310 INPUT"EXPECTED FREQUENCIES ";E:PRINT
3320 IF E=0 THEN 3350
3330 K=((D-E)^2)/E:J=J+K
3340 GOTO 3300
3350 PRINT:PRINT"CHI-SQUARE = ";J:PRINT:PRINT
3360 GOSUB 4090:PRINT:GOTO 3280
3370 GOSUB 4070
3380 PRINT"              THE FACTORIALS OF (X) BY ITERATIVE MULTIPLICATIONS"
3390 PRINT
3400 INPUT"INPUT VALUE(X)";Y:PRINT
3410 Z=1:FOR I=1 TO Y:Z=Z*I:NEXT I
3420 PRINT TAB(34)"X = ";Y,"X! = ";Z
3430 GOSUB 4090:PRINT:GOTO 3400
3440 GOSUB 4070
3450 PRINT"A TABLE OF  FIBONACCI NUMBERS"
3460 PRINT:PRINT
3470 INPUT"ENTER FIRST TERM";A:PRINT
3480 INPUT"ENTER SECOND TERM";B:PRINT
3490 INPUT"MAXIMUM NUMBER OF TERMS";N:PRINT
3500 PRINT"TABLE OF FIBONACCI NUMBERS"
3510 PRINT"TERM #","FIBONACCI NUMBER":PRINT
3520 K=1:PRINT K,A:K=2:PRINT K,B
3530 K=K+1:Q=A+B:PRINT K,Q:A=B:B=Q
3540 IF K=>N THEN 3560
3550 GOTO 3530
3560 PRINT:PRINT"MAXIMUM NUMBER OF TERMS REACHED":PRINT
3570 GOSUB 4090:PRINT:GOTO 3470
3580 GOSUB 4070
3590 LOCATE 5,18:PRINT"THIS PROGRAM COMPUTES BOTH THE GAMMA FUNCTION AND THE"
3600 LOCATE 7,19:PRINT"GENERALIZED FACTORIAL VIA POLYNOMIAL APPROXIMATION."
3610 A=.57717:B=.9882099:C=.89706:D=.91821:E=.7567:F=.4822
3620 G=.19353:H=.03587
3630 LOCATE 9,24:PRINT"TYPE -G- FOR THE GAMMA FUNCTION"
3640 LOCATE 10,24:PRINT"TYPE -F- FOR THE GENERALIZED FACTORIAL":A$=INPUT$(1)
3650 IF A$="G" THEN LOCATE 9,22:PRINT"?":GOTO 3710
3660 IF A$="F" THEN LOCATE 10,22:PRINT"?":GOTO 3800
3670 'IF A$="G" THEN 5426
3680 'IF A$="F" THEN 5446
3690 PRINT "INVALID RESPONSE TRY AGAIN !!!!!$%&#??"
3700 GOTO 3630
3710 LOCATE 12,32:INPUT"ENTER VALUE OF (X)";X1
3720 K=X1:K=K-1
3730 IF K>=0 THEN 3760
3740 PRINT"(X) MUST BE EQUAL TO OR GREATER THAN '1'":PRINT
3750 GOTO 3710
3760 GOSUB 3920
3770 IF (X1-1)=INT(X1-1) THEN 3900
3780 GOSUB 4000
3790 GOTO 3900
3800 LOCATE 12,32:INPUT"ENTER THE VALUE OF (X)";X1:PRINT
3810 K=X1
3820 IF K>=0 THEN 3850
3830 PRINT"(X) MUST BE GREATER THAN OR EQUAL TO '0'":PRINT
3840 GOTO 3800
3850 GOSUB 3920
3860 IF X1=INT(X1) THEN 3880
3870 GOSUB 4000
3880 PRINT                                             X1;" = ";K
3890 GOTO 3910
3900 PRINT:PRINT"                                GAMMA (";X1;") = ";K
3910 GOTO 4050
3920 J=1
3930 J=J*K
3940 K=K-1
3950 IF K<1 THEN 3970
3960 GOTO 3930
3970 L=K
3980 K=J
3990 RETURN
4000 A1=1+(A*L)+(B*(L^2))+(C*(L^3))
4010 A1=A1+(D*(L^4))+(E*(L^5))+(F*(L^6))
4020 A1=A1+(G*(L^7))+(H*(L^8))
4030 K=A1*K
4040 RETURN
4050 GOSUB 4090:PRINT:GOTO 3630
4060  ON  A  GOTO  540,830,650,1080,1270,1450,1550,1740,1930,2070,2200,2600,2780,2870,2970,3130,3240,3370,3440,3580,5500,5600,5700,5800,6000,6100,6200,6300,6400,6500,6600,6700,7000,7100,7200,7600,7700,7800,7900,7950
4070 PRINT CHR$(12):LOCATE 4,1:Z$=STRING$(80,CHR$(205)):PRINT Z$
4080 PRINT:RETURN
4090 FOR I=79 TO 2 STEP-1:LOCATE 23,I:PRINT"?":NEXT I
4100 B$=INKEY$:IF B$="Y"THEN PRINT CHR$(12):RETURN
4110 IF B$="N" THEN GOTO 4230
4120 FOR I=79 TO 2 STEP-1:LOCATE 23,I:PRINT"?":NEXT I
4130 B$=INKEY$:IF B$="Y" THEN PRINT CHR$(12):RETURN
4140 IF B$="N" THEN GOTO 4230
4150 FOR I=79 TO 2 STEP-1:LOCATE 23,I:PRINT"?":NEXT I
4160 B$=INKEY$:IF B$="Y" THEN PRINT CHR$(12):RETURN
4170 IF B$="N" THEN GOTO 4230
4180 LOCATE 23,2:COLOR 0,7:PRINT" WOULD YOU LIKE ANOTHER TRY ? ":COLOR 7
4190 FOR J=1 TO 800:NEXT J:COLOR 7
4200 IF B$="Y" THEN PRINT CHR$(12):RETURN
4210 IF B$="N" THEN GOTO 4230
4220 IF B$= "" THEN 4090
4230 PRINT CHR$(12):GOTO 310
4240 COLOR 15:LOCATE 1,2:PRINT"?":LOCATE 1,3:FOR I=1 TO 35:PRINT"?";:NEXT I:LOCATE 1,38:PRINT"?":FOR I=2 TO 21:LOCATE I,38:PRINT"?":NEXT I:LOCATE 22,38:PRINT"?":FOR I=37 TO 3 STEP-1:LOCATE 22,I:PRINT"?":NEXT I:LOCATE 22,2:PRINT"?"
4250 FOR I=21 TO 2 STEP-1:LOCATE I,2:PRINT"?":NEXT I
4260 REM LOCATE 1,42:PRINT"?":LOCATE 1,43:FOR I=1 TO 36:PRINT"?";:NEXT I:LOCATE 1,79:PRINT"?":FOR I=2 TO 21:LOCATE I,79:PRINT"?":NEXT I:LOCATE 22,79:PRINT"?":FOR I=78 TO 43 STEP-1:LOCATE 22,I:PRINT"?":NEXT I:LOCATE 22,42:PRINT"?"
4270 REM I=21 TO 2 STEP-1:LOCATE I,42:PRINT"?":NEXT I
4280 RETURN
4290 LOCATE 24,22:PRINT"When ready ? PRESS SPACE BAR or PROGRAM NUMBER"
4300 LOCATE 24,70
4310 COLOR 0,2
4320 A$=INPUT$(1):IF A$=" " THEN 61400
4330 A=VAL(A$):PRINT CHR$(12):RETURN
4340 C=VAL(C$):PRINT CHR$(12)
4350 ON C GOTO 1740,1840,1940,2040,2140
=" " THEN 61400
43