Pagini recente » Cod sursa (job #1342495) | Cod sursa (job #3032950) | Cod sursa (job #1840418) | Cod sursa (job #96953) | Cod sursa (job #164769)
Cod sursa(job #164769)
var n,i,j,p:longint;
s:array[1..1000000] of longint;
f:text;
function gcd(a,b:longint):longint;
var g:longint;
begin
while a > 0 Do Begin
g := a;
a := b Mod a;
b := g;
end;
gcd := g;
end;
begin
assign(f,'fractii.in');reset(f);
read(f,n);
assign(f,'fractii.out');rewrite(f);
for i := 1 to n do
s[i] := n;
for i := 1 to n do
for j := 1 to n do
begin
p:=2;
if gcd(i,j)=1 then
while (i*p<=n) AND (j*p<=n) do
begin
dec(s[i*p]);
inc(p);
end;
end;
j:=0;
for i :=1 to n do
inc(j,s[i]);
write(f,j);
close(f);
end.