blob: aeb64d4b38664526d08edd68fc7ba41c6bf77db4 (
plain)
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
|
(*
To compile and run:
$ fpc ch-1.pas
$ ./ch-1 100
13015
*)
program Hello(input, output);
uses sysutils;
var
n, x, y, s: integer;
function gcd(a, b: integer): integer;
var
t: integer;
begin
while b <> 0 do begin
t := b;
b := a mod b;
a := t;
end;
gcd := a
end;
begin
if paramCount() = 0 then
n := 3
else
n := StrToInt(paramStr(1));
s := 0;
for x := 1 to n do
for y := x + 1 to n do
s += gcd(x, y);
writeln(s);
end.
|