mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 15:28:08 +02:00

that was set during the typecheck pass because typeconversion nodes may have been optimised away previously and sometimes the resultdef is important (e.g. for the value of callparanodes) (mantis #17458) git-svn-id: trunk@16101 -
20 lines
377 B
ObjectPascal
20 lines
377 B
ObjectPascal
function TailRecFibonacci(const n: Byte): QWord;
|
|
|
|
function InnerFibo(const n: Byte; const r1,r2: QWord): QWord; inline;
|
|
begin
|
|
case n of
|
|
0: InnerFibo := r1;
|
|
1: InnerFibo := r2;
|
|
else InnerFibo := InnerFibo(n - 1,r2,r1 + r2);
|
|
end;
|
|
end;
|
|
|
|
begin
|
|
TailRecFibonacci := InnerFibo(n,0,1);
|
|
end;
|
|
|
|
begin
|
|
if TailRecFibonacci(10)<>55 then
|
|
halt(1);
|
|
end.
|