-
Notifications
You must be signed in to change notification settings - Fork 0
/
GGTKGV.PAS
executable file
·107 lines (104 loc) · 1.81 KB
/
GGTKGV.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
program ggtkgv;
uses crt,u1;
var hilfe,ha,hb,a,b,n,k,z,l,m: longint;
wahl:char;
procedure farbe;
begin
textbackground(7);
textcolor(1);
for z:=1 to 80 do
begin (*wp('Text',10,5);*)
for m:=1 to 25 do
begin
gotoxy(z,m);
write(' ');
end;
end;
end;
procedure faktor;
begin
farbe;
gotoxy(12,4);
write('Bestimmung des ggT und des kgV zweier Zahlen: ');
gotoxy(20,6);
write('a =');
read(a);
gotoxy(40,6);
write('b =');
read(b);
gotoxy(10,10);
write('a = ',a,' = ');
gotoxy(21,10);
write('1');
ha:=a;
hb:=b;
for n:=2 to a do
begin
while (trunc(ha/n))*n=ha do
begin
ha:=trunc(ha/n);
write('*',n);
end;
end;
gotoxy(10,12);
write('b = ',b,' = ');
gotoxy(21,12);
write('1');
for n:=2 to b do
begin
while (trunc(hb/n))*n=hb do
begin
hb:=trunc(hb/n);
write('*',n);
end;
end;
ha:=a;
hb:=b;
gotoxy(10,15);
write('ggT(a,b) = 1');
k:=1;
for n:=2 to a do
begin
while ((trunc(hb/n))*n=hb) and ((trunc(ha/n))*n=ha) do
begin
ha:=trunc(ha/n);
hb:=trunc(hb/n);
write('*',n);
k:=k*n;
end;
end;
write(' = ',k);
ha:=a;
hb:=b;
gotoxy(10,17);
write('kgV(a,b) = 1');
hilfe:=0;
repeat
hilfe:=hilfe+a;
until trunc(hilfe/b)*b=hilfe;
hb:=hilfe;
for n:=2 to hilfe do
begin
while (trunc(hb/n))*n=hb do
begin
hb:=trunc(hb/n);
write('*',n);
k:=k*n;
end;
end;
write(' = ',hilfe);
end;
begin
clrscr;
farbe;
faktor;
repeat
gotoxy(10,24);
write('Beenden: "0" Wiederholen: "1" ' );
read(wahl);
case wahl of
'1':faktor;
else
end;
until wahl='0';
end.