Pagini recente » Cod sursa (job #1898292) | Cod sursa (job #2736454) | Cod sursa (job #739794) | Cod sursa (job #2935512) | Cod sursa (job #120663)
Cod sursa(job #120663)
type vec=array[1..1000000] of byte;
var i,j,k,nr,n,k1:int64;
p:vec;
begin
assign(input,'fractii.in');
assign(output,'fractii.out');
reset(input);
rewrite(output);
read(n);
k:=n-1; {numarul fractiilor reductibile de forma 2/2 3/3...}
i:=2;
while i<(n div 2) do
begin
k1:=0;
if p[i]=0 then
begin
j:=i+i;
while j<=n do
begin
k:=k+2;
p[j]:=1;
j:=j+i;
inc(k1);
end;
end;
if k1<>0 then k:=k+(k1*(k1+1) div 2);
inc(i);
end;
nr:=n*n-k; {din numarul fractiilor existente scadem fractiile reductibile}
write(nr);
close(input);
close(output);
end.