1
0
mirror of https://github.com/mbirth/gwbasic.git synced 2024-12-25 12:04:08 +00:00

Added PRIMZAHL files.

This commit is contained in:
Markus Birth 1995-12-14 19:19:08 +01:00
parent 8111829b64
commit 6c4123dffa
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
7 changed files with 375 additions and 0 deletions

88
PRIMZAHL/PRIM.BAS Normal file
View File

@ -0,0 +1,88 @@
5 STP=40
6 DIM TIR(STP+1)
10 CLS
20 COLOR 15
30 INPUT "Geben Sie den Anfangswert f<>r die Primzahlen an:", ANF
40 IF ANF = 0 THEN ANF = 1
50 INPUT "Geben Sie den Maximalwert f<>r die Primzahlen an:", MAX
60 CLS
70 HOUR=VAL(LEFT$(TIME$,2)):MINU=VAL(MID$(TIME$,4,2)):SEC=VAL(RIGHT$(TIME$,2)):TI=MINU+(SEC/100)/.6
80 DIM V(MAX - ANF)
90 B = 12
100 C = 0
110 L = 1
120 G = 9
130 H = 1
140 A = ANF
150 U = ANF
160 FOR Z = 1 TO A
170 Y = A / Z
180 HOURD=VAL(LEFT$(TIME$,2)):MIND=VAL(MID$(TIME$,4,2)):SECD=VAL(RIGHT$(TIME$,2))
181 MIND=MIND+((HOURD-HOUR)*60)
182 TID=MIND+(SECD/100)/.6
190 TIDIFF=TID-TI:MN=INT(TIDIFF):SC=(TIDIFF-MN)*100*.6
195 IF PER=0 THEN 260
200 NOW=NOW+1
210 TIR(NOW)=TIDIFF/(PER/100)
220 IF NOW=STP THEN NOW=0 ELSE 260
230 FOR NUMM=1 TO STP
240 TIR=TIR+TIR(NUMM)
250 NEXT NUMM
251 TIR=TIR/STP
252 BM=INT(TIR):BS=((TIR)-BM)*100*.6
260 LOCATE 1, 1: PRINT USING "Aktuelles Ergebnis: #####.###### Zeit: ##:##";Y;MN;SC
270 LOCATE 2, 1: PRINT USING "Momentaner Teiler : ##### noch: ##:##";Z;BM;BS
280 LOCATE 3, 1: PRINT USING " schon #####x geteilt"; X
290 LOCATE 4, 1: PRINT USING "Aktuelle Zeile : #####"; B - 11
300 LOCATE 5, 1: PRINT USING "Primzahlen insges.: #####"; C
310 PER = ((A - ANF) * 100) / (MAX - ANF): IF ANF = 1 THEN PER = (A * 100) / MAX
320 LOCATE 6, 1: PRINT USING "Aktuelle Zahl : ##### von ##### das sind ###.##%"; A; MAX; PER
330 LOCATE 7, 1: PRINT USING " Noch ##### Werte"; MAX - A
340 LOCATE 11, 1: PRINT SPACE$(80)
350 IF Y = INT(Y) THEN GOSUB 750
360 NEXT Z
370 LOCATE 9, 1: PRINT SPACE$(80)
380 LOCATE 10, 1: PRINT SPACE$(80)
390 G = 9
400 H = 1
410 IF X = 2 OR A = 1 THEN GOSUB 470
420 X = 0
430 A = A + 1
440 IF A > MAX THEN LOCATE 23, 1: GOTO 560
450 IF W = 1 THEN GOSUB 530: W = 0
460 GOTO 160
470 REM Unterroutine
480 LOCATE 3, 60: SOUND 2000, .5
490 COLOR 12, 0, 0: PRINT "Primzahl gefunden...": COLOR 14, 0, 0: C = C + 1: X = 0
500 LOCATE B, L: PRINT USING"#####";A: L = L + 6: IF L > 75 THEN L = 1: B = B + 1: IF B > 23 THEN B = 12: L = 1
510 V(U) = A: U = U + 1: W = 1
520 RETURN
530 REM Unterroutine
540 COLOR 15, 0, 0: LOCATE 3, 60: PRINT SPACE$(20)
550 RETURN
560 REM Endroutine
570 PRINT "Wenn fertig Taste dr<64>cken..."
580 A$ = INKEY$: IF A$ = "" THEN 580
590 CLS
600 COLOR 14, 0, 0
610 A = 1
620 B = 1
630 C = 1
640 L = 1
650 FOR Z = ANF TO MAX
660 IF V(Z) = 0 THEN GOTO 700
670 LOCATE B, C: PRINT V(Z)
680 C = C + 5: IF L > 75 THEN B = B + 1: C = 1: IF B > 23 THEN B = 1
690 NEXT Z
700 COLOR 10
710 LOCATE 23, 1: PRINT "Wenn bereit Taste dr<64>cken..."
720 A$ = INKEY$: IF A$ = "" THEN 720
730 CLS : COLOR 15, 0, 0
740 END
750 REM Teiler in Q
760 X = X + 1
770 LOCATE G, H: COLOR 10: PRINT USING "#####";Z: H = H + 6: IF H > 75 THEN G = G + 1: H = 1
780 IF G > 10 THEN G = 9
790 COLOR 15
800 RETURN


13
PRIMZAHL/PRIM1.BAS Normal file
View File

@ -0,0 +1,13 @@
10 CLS
20 B=5
30 C=1
40 A=1
50 FOR Z=1 TO A
60 Y=A/Z
70 LOCATE 1,1:PRINT Y;" "
80 LOCATE 2,1:PRINT A;" "
90 IF Y=INT(Y) THEN X=X+1:IF A=D THEN 110 ELSE LOCATE B,C:PRINT A:D=A:C=C+3:IF C>75 THEN B=B+1:C=1
110 NEXT Z
120 A=A+1
130 GOTO 50


48
PRIMZAHL/PRIM2.BAS Normal file
View File

@ -0,0 +1,48 @@
10 CLS
20 INPUT"Geben Sie den Maximalwert f<>r die Primzahlen an:",MAX
30 CLS
40 DIM V(MAX)
50 B=5
60 C=1
70 A=1
80 U=1
90 FOR Z=1 TO A
100 Y=A/Z
110 LOCATE 1,1:PRINT Y;" "
120 LOCATE 2,1:PRINT A;" "
130 IF Y=INT(Y) THEN X=X+1
140 NEXT Z
150 IF X=2 OR A=1 THEN GOSUB 210
160 X=0
170 A=A+1
180 IF A>MAX THEN LOCATE 23,1:GOTO 310
190 IF W=1 THEN GOSUB 280:W=0
200 GOTO 90
210 REM Unterroutine
220 LOCATE 3,1:SOUND 2000,.5
230 COLOR 12,0,0:PRINT"Primzahl gefunden...":COLOR 14,0,0
240 X=0:LOCATE B,C:PRINT A:C=C+5:IF C>75 THEN C=1:B=B+1
250 V(U)=A:U=U+1
260 COLOR 15,0,0:LOCATE 3,1:PRINT"Primzahl gefunden..."
270 RETURN
280 REM Unterroutine
290 COLOR 15,0,0:LOCATE 3,1:PRINT"Primzahl gefunden..."
300 RETURN
310 REM Endroutine
320 PRINT"Wenn fertig Taste dr<64>cken..."
330 A$=INKEY$:IF A$="" THEN 330
340 CLS
350 COLOR 14,0,0
360 A=1
370 B=1
380 C=1
390 FOR Z=1 TO MAX
400 IF V(Z)=0 THEN GOTO 430
410 LOCATE B,C:PRINT V(Z)
420 C=C+5:IF C>75 THEN B=B+1:C=1
430 NEXT Z
440 COLOR 10
450 LOCATE 23,1:PRINT"Wenn bereit Taste dr<64>cken..."
460 A$=INKEY$:IF A$="" THEN 460
470 CLS:COLOR 15,0,0


70
PRIMZAHL/PRIMF2.BAS Normal file
View File

@ -0,0 +1,70 @@
10 CLS
20 COLOR 15
30 INPUT"Geben Sie den Anfangswert f<>r die Primzahlen an:",ANF
40 IF ANF=0 THEN ANF=1
50 INPUT"Geben Sie den Maximalwert f<>r die Primzahlen an:",MAX
60 CLS
70 DIM V(MAX)
80 B=12
90 C=1
100 G=9
110 H=1
120 A=ANF
130 U=1
140 FOR Z=1 TO A
150 Y=A/Z
160 LOCATE 1,1:PRINT "Akt. Ergebnis: ";Y;" "
170 LOCATE 2,1:PRINT "Mom. Teiler : ";Z;" "
180 LOCATE 3,1:PRINT " schon ";X;"x geteilt "
190 LOCATE 4,1:PRINT "Akt. Zeile : ";B-11;" "
200 LOCATE 5,1:PRINT "Primzahlen : ";(C-1)/5;" "
210 LOCATE 6,1:PRINT "Akt. Zahl : ";A;"von ";MAX;" "
220 LOCATE 7,1:PRINT " Noch ";MAX-A;" Werte "
230 LOCATE 11,1:PRINT SPACE$(80)
240 IF Y=INT(Y) THEN GOSUB 630
250 NEXT Z
260 LOCATE 9,1:PRINT SPACE$(80)
270 LOCATE 10,1:PRINT SPACE$(80)
280 G=9
290 H=1
300 IF X=2 OR A=1 THEN GOSUB 360
310 X=0
320 A=A+1
330 IF A>MAX THEN LOCATE 23,1:GOTO 450
340 IF W=1 THEN GOSUB 420:W=0
350 GOTO 140
360 REM Unterroutine
370 LOCATE 3,33:SOUND 2000,.5
380 COLOR 12,0,0:PRINT"Primzahl gefunden...":COLOR 14,0,0
390 X=0:LOCATE B,C:PRINT A:C=C+5:IF C>75 THEN C=1:B=B+1:IF B>23 THEN B=12:C=1
400 V(U)=A:U=U+1:W=1
410 RETURN
420 REM Unterroutine
430 COLOR 15,0,0:LOCATE 3,33:PRINT" "
440 RETURN
450 REM Endroutine
460 PRINT"Wenn fertig Taste dr<64>cken..."
470 A$=INKEY$:IF A$="" THEN 470
480 CLS
490 COLOR 14,0,0
500 A=1
510 B=1
520 C=1
530 FOR Z=1 TO MAX
540 IF V(Z)=0 THEN GOTO 570
550 LOCATE B,C:PRINT V(Z)
560 C=C+5:IF C>75 THEN B=B+1:C=1:IF B>23 THEN B=1
570 NEXT Z
580 COLOR 10
590 LOCATE 23,1:PRINT"Wenn bereit Taste dr<64>cken..."
600 A$=INKEY$:IF A$="" THEN 600
610 CLS:COLOR 15,0,0
620 END
630 REM Teiler in Q
640 X=X+1
650 IF X>2 THEN 310
660 IF X>=2 AND Z<A THEN 310
670 LOCATE G,H:COLOR 10:PRINT Y:H=H+5:IF H>75 THEN G=G+1:H=1
680 COLOR 15
690 RETURN


56
PRIMZAHL/PRIMFAST.BAS Normal file
View File

@ -0,0 +1,56 @@
10 CLS
20 COLOR 15
30 INPUT"Geben Sie den Maximalwert f<>r die Primzahlen an:",MAX
40 CLS
50 DIM V(MAX)
60 B=12
70 C=1
80 A=1
90 U=1
100 FOR Z=1 TO A
110 Y=A/Z
120 LOCATE 1,1:PRINT "Akt. Ergebnis: ";Y;" "
130 LOCATE 2,1:PRINT "Mom. Teiler : ";Z;" "
140 LOCATE 3,1:PRINT " schon ";X;"x geteilt "
150 LOCATE 4,1:PRINT "Akt. Zeile : ";B-11;" "
160 LOCATE 5,1:PRINT "Primzahlen : ";(C-1)/5;" "
170 LOCATE 6,1:PRINT "Akt. Zahl : ";A;"von ";MAX;" "
180 LOCATE 7,1:PRINT " Noch ";MAX-A;" Werte "
190 LOCATE 11,1:PRINT SPACE$(80)
200 IF Y=INT(Y) THEN X=X+1
210 IF X>2 THEN 250
220 IF X=2 AND Z<A THEN 250
230 NEXT Z
240 IF X=2 OR A=1 THEN GOSUB 300
250 X=0
260 A=A+1
270 IF A>MAX THEN LOCATE 23,1:GOTO 390
280 IF W=1 THEN GOSUB 360:W=0
290 GOTO 100
300 REM Unterroutine
310 LOCATE 3,33:SOUND 2000,.5
320 COLOR 12,0,0:PRINT"Primzahl gefunden...":COLOR 14,0,0
330 X=0:LOCATE B,C:PRINT A:C=C+5:IF C>75 THEN C=1:B=B+1:IF B>23 THEN B=12:C=1
340 V(U)=A:U=U+1:W=1
350 RETURN
360 REM Unterroutine
370 COLOR 15,0,0:LOCATE 3,33:PRINT" "
380 RETURN
390 REM Endroutine
400 PRINT"Wenn fertig Taste dr<64>cken..."
410 A$=INKEY$:IF A$="" THEN 410
420 CLS
430 COLOR 14,0,0
440 A=1
450 B=1
460 C=1
470 FOR Z=1 TO MAX
480 IF V(Z)=0 THEN GOTO 510
490 LOCATE B,C:PRINT V(Z)
500 C=C+5:IF C>75 THEN B=B+1:C=1:IF B>23 THEN B=1
510 NEXT Z
520 COLOR 10
530 LOCATE 23,1:PRINT"Wenn bereit Taste dr<64>cken..."
540 A$=INKEY$:IF A$="" THEN 540
550 CLS:COLOR 15,0,0


72
PRIMZAHL/PRIMZ.BAS Normal file
View File

@ -0,0 +1,72 @@
10 CLS
20 COLOR 15
30 INPUT "Geben Sie den Anfangswert f<>r die Primzahlen an:", ANF
40 IF ANF = 0 THEN ANF = 1
50 INPUT "Geben Sie den Maximalwert f<>r die Primzahlen an:", MAX
60 CLS
70 DIM V(MAX - ANF)
80 B = 12
90 C = 0
100 L = 1
110 G = 9
120 H = 1
130 A = ANF
140 U = ANF
150 FOR Z = 1 TO A
160 Y = A / Z
170 LOCATE 1, 1: PRINT USING "Aktuelles Ergebnis: #####.######"; Y
180 LOCATE 2, 1: PRINT USING "Momentaner Teiler : #####"; Z
190 LOCATE 3, 1: PRINT USING " schon #####x geteilt"; X
200 LOCATE 4, 1: PRINT USING "Aktuelle Zeile : #####"; B - 11
210 LOCATE 5, 1: PRINT USING "Primzahlen insges.: #####"; C
220 PER = ((A - ANF) * 100) / (MAX - ANF): IF ANF = 1 THEN PER = (A * 100) / MAX
230 LOCATE 6, 1: PRINT USING "Aktuelle Zahl : ##### von ##### das sind ###.##%"; A; MAX; PER
240 LOCATE 7, 1: PRINT USING " Noch ##### Werte"; MAX - A
250 LOCATE 11, 1: PRINT SPACE$(80)
260 IF Y = INT(Y) THEN GOSUB 660
270 NEXT Z
280 LOCATE 9, 1: PRINT SPACE$(80)
290 LOCATE 10, 1: PRINT SPACE$(80)
300 G = 9
310 H = 1
320 IF X = 2 OR A = 1 THEN GOSUB 380
330 X = 0
340 A = A + 1
350 IF A > MAX THEN LOCATE 23, 1: GOTO 470
360 IF W = 1 THEN GOSUB 440: W = 0
370 GOTO 150
380 REM Unterroutine
390 LOCATE 3, 60: SOUND 2000, .5
400 COLOR 12, 0, 0: PRINT "Primzahl gefunden...": COLOR 14, 0, 0: C = C + 1: X = 0
410 LOCATE B, L: PRINT USING"#####";A: L = L + 6: IF L > 75 THEN L = 1: B = B + 1: IF B > 23 THEN B = 12: L = 1
420 V(U) = A: U = U + 1: W = 1
430 RETURN
440 REM Unterroutine
450 COLOR 15, 0, 0: LOCATE 3, 60: PRINT SPACE$(20)
460 RETURN
470 REM Endroutine
480 PRINT "Wenn fertig Taste dr<64>cken..."
490 A$ = INKEY$: IF A$ = "" THEN 490
500 CLS
510 COLOR 14, 0, 0
520 A = 1
530 B = 1
540 C = 1
550 L = 1
560 FOR Z = ANF TO MAX
570 IF V(Z) = 0 THEN GOTO 610
580 LOCATE B, C: PRINT V(Z)
590 C = C + 5: IF L > 75 THEN B = B + 1: C = 1: IF B > 23 THEN B = 1
600 NEXT Z
610 COLOR 10
620 LOCATE 23, 1: PRINT "Wenn bereit Taste dr<64>cken..."
630 A$ = INKEY$: IF A$ = "" THEN 630
640 CLS : COLOR 15, 0, 0
650 END
660 REM Teiler in Q
670 X = X + 1
680 LOCATE G, H: COLOR 10: PRINT USING "#####";Z: H = H + 6: IF H > 75 THEN G = G + 1: H = 1
690 IF G > 10 THEN G = 9
700 COLOR 15
710 RETURN


28
PRIMZAHL/PRIMZABF.BAS Normal file
View File

@ -0,0 +1,28 @@
10 CLS
20 INPUT"Geben Sie den Maximalwert f<>r die Primzahlen an:",MAX
30 CLS
40 B=5
50 C=1
60 A=1
70 FOR Z=1 TO A
80 Y=A/Z
90 LOCATE 1,1:PRINT Y;" "
100 LOCATE 2,1:PRINT A;" "
110 IF Y=INT(Y) THEN X=X+1
120 NEXT Z
130 IF X=2 OR A=1 THEN GOSUB 190
140 X=0
150 A=A+1
160 IF A>MAX THEN LOCATE 23,1:END
170 IF W=1 THEN GOSUB 250:W=0
180 GOTO 70
190 REM Unterroutine
200 LOCATE 3,1:SOUND 2000,.5
210 COLOR 12,0,0:PRINT"Primzahl gefunden...":COLOR 14,0,0
220 X=0:LOCATE B,C:PRINT A:C=C+5:IF C>75 THEN C=1:B=B+1
230 COLOR 15,0,0:LOCATE 3,1:PRINT"Primzahl gefunden..."
240 RETURN
250 REM Unterroutine
260 COLOR 15,0,0:LOCATE 3,1:PRINT"Primzahl gefunden..."
270 RETURN