Pagini recente » Cod sursa (job #1290841) | Cod sursa (job #1838686) | Cod sursa (job #1601832) | Cod sursa (job #2060545) | Cod sursa (job #152290)
Cod sursa(job #152290)
var n,i,q:longint;
f,g:text;
a,b,c:string;
function adun(x,y:string):string;
var i,t,max,q:integer;
z:string;
begin
z:='';
max:=length(x);
if max<length(y) then max:=length(y);
if length(x)>length(y) then
for i:=1 to length(x)-length(y) do y:='0'+y
else
for i:=1 to length(y)-length(x) do x:='0'+x;
t:=0;
for i:=max downto 1 do begin
q:=t+ord(x[i])-48+ord(y[i])-48;
z:=chr((q mod 10)+48)+z;
q:=q div 10;
t:=q;
end;
if t<>0 then z:=chr(t+48)+z;
if z='' then z:='0';
adun:=z;
end;
{function scad(x,y:string):string;
var i,t,q:integer;
z:string;
begin
z:='';
if length(x)>length(y) then
for i:=1 to length(x)-length(y) do y:='0'+y;
for i:=length(x) downto 1 do begin
if x[i]<y[i] then begin
t:=10;
x[i-1]:=pred(x[i-1]);
end
else t:=0;
q:=t+ord(x[i])-48-(ord(y[i])-48);
z:=chr(q+48)+z;
end;
if z[1]='0' then delete(z,1,1);
if z='' then z:='0';
scad:=z;
end;}
begin
assign(f,'nunta.in');
assign(g,'nunta.out');
reset(f);
rewrite(g);
readln(f,n);
close(f);
if n=1 then write(g,'1');
if n=2 then write(g,'2');
if n>2 then
begin
a:='1';
b:='2';
i:=2;
while i<n do begin
inc(i);
c:=adun(a,b);
a:=b;
b:=c;
end;
writeln(g,c);
end;
close(g);
end.