Pagini recente » Cod sursa (job #2230923) | Cod sursa (job #2235297) | Cod sursa (job #2191339) | Cod sursa (job #2160608) | Cod sursa (job #30281)
Cod sursa(job #30281)
program fractii;
var x:longint;
p,i:longint;
f:text;
function prim(a:longint):boolean;
var i:word;
begin
prim:=true;
for i:=2 to round(sqrt(a)) do
if a mod i=0 then
begin
prim:=false;
break;
end;
end;
function tot(a:longint):longint;
var i:word;
x:double;
begin
x:=a;
if prim(a) then x:=x-1 else
begin
for i:=1 to round(a/2) do
if (a mod i=0)and(i<>1)and prim(i) then
x:=x*(1-1/i);
end;
tot:=round(x);
end;
begin
assign(f,'fractii.in');
reset(f);
read(f,p);
close(f);
assign(f,'fractii.out');
rewrite(f);
for i:=2 to p do
x:=x+2*tot(i);
{ write(f,tot(6),',');}
write(f,x+1);
close(f);
end.