Pagini recente » Cod sursa (job #1884774) | Cod sursa (job #1686587) | Cod sursa (job #1268660) | Cod sursa (job #2367084) | Cod sursa (job #387532)
Cod sursa(job #387532)
program pascal;
var
f:text;
n,i,j,count:longint;
function cmmdc(a,b:longint):boolean;
begin
while a<>b do
if a>b then
a:=a-b
else b:=b-a;
if a=1 then
cmmdc:=true
else cmmdc:=false;
end;
begin
assign(f,'fractii.in');
reset(f);
read(f,n);
close(f);
count:=1;
for i:=1 to n-1 do begin
j:=i+1;
if i mod 2 = 0 then
while j<=n do begin
if cmmdc(i,j) then
inc(count,2);
inc(j,2);
end
else
for j:=i+1 to n do
if cmmdc(i,j) then
inc(count,2);
end;
assign(f,'fractii.out');
rewrite(f);
write(f,count);
close(f);
end.