Hello,
I've stumbled across an unusual problem with this following program while using Turbo Pascal 3:
The problem being the correct sequence of numbers isn't being produced. It's starts fine with 1, 1, but then it counts up to 15. The code is on Progopedia and includes Turbo Pascal 3 as part of the compilers which can compile. I'm using the CP/M version which has been tweaked for the Amstrad CPC computers, so I'm assuming it works correctly for the 16bit versions, but don't know if other CP/M versions of TP3 are struggling with this?
I've stumbled across an unusual problem with this following program while using Turbo Pascal 3:
Code:
program fibonacci;
function fib(n:integer): integer;
begin
if (n <= 2) then
fib := 1
else
fib := fib(n-1) + fib(n-2);
end;
var
i:integer;
begin
for i := 1 to 16 do
write(fib(i), ', ');
writeln('...');
end.
The problem being the correct sequence of numbers isn't being produced. It's starts fine with 1, 1, but then it counts up to 15. The code is on Progopedia and includes Turbo Pascal 3 as part of the compilers which can compile. I'm using the CP/M version which has been tweaked for the Amstrad CPC computers, so I'm assuming it works correctly for the 16bit versions, but don't know if other CP/M versions of TP3 are struggling with this?