Pagini recente » Cod sursa (job #2777307) | Cod sursa (job #2640970) | Cod sursa (job #207433) | Cod sursa (job #559768) | Cod sursa (job #352867)
Cod sursa(job #352867)
var n,k,i,j:longint;
function cmmdc(i,j:longint):boolean;
begin
while (i<>0) and (j<>0) do
if i>j then i:=i-j
else j:=j-i;
if i<=j then i:=j;
if i=1 then cmmdc:=true
else cmmdc:=false;
end;
begin
assign(input,'fractii.in');
reset(input);
readln(input,n);
close(input);
k:=(2*n)-1;
k:=k+(n div 2+n mod 2)-1;
for i:=3 to n do
for j:=2 to n do
if cmmdc(i,j)=true then inc(k);
assign(output,'fractii.out');
rewrite(output);
write(output,k);
close(output);
end.