Pagini recente » Cod sursa (job #2153483) | Cod sursa (job #2452742) | Cod sursa (job #2309021) | Cod sursa (job #539438) | Cod sursa (job #42583)
Cod sursa(job #42583)
var s,i,n:longint;
begin
assign(input,'fractii.in');
reset(input);
assign(output,'fractii.out');
rewrite(output);
readln(n);
if n=1 then writeln(1)
else
if n=2 then writeln(2)
else
if n=3 then writeln(7)
else
begin
s:=7;
for i:=4 to n do
begin
if i mod 2=0 then
begin
s:=s+i;
if (i div 2) mod 2=1 then
s:=s-2
end
else
begin
s:=s+2*i-2;
end;
end;
writeln(s);
end;
close(output);
end.