I've stumbled across an unusual problem with this following program while using Turbo Pascal 3:
function fib(n:integer): integer;
if (n <= 2) then
fib := 1
fib := fib(n-1) + fib(n-2);
for i := 1 to 16 do
write(fib(i), ', ');
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?