function Reverse(a : Integer) : Integer;
var
r,c : Integer;
begin
if a div 10 = 0 then
begin
result := a;
end
else
begin
result := Reverse(a div 10);
c := 0;
r := a mod 10;
while a div 10 <> 0do
begin
inc(c);
a :=a div 10;
end;
while c <>0do
begin
r := r*10;
dec(c);
end;
result := r + result;
end;
end;