cpp-peglib/language/pl0/samples/fib.pas

31 lines
404 B
ObjectPascal
Raw Normal View History

2015-08-05 15:54:32 +00:00
VAR i, x, r;
PROCEDURE fib;
VAR xx, r1, r2;
BEGIN
xx := x;
IF xx = 0 THEN r := 1;
IF xx = 1 THEN r := 1;
IF xx >= 2 THEN BEGIN
x := xx - 2;
CALL fib;
r1 := r;
x := xx - 1;
CALL fib;
r2 := r;
r := r1 + r2;
END
END;
BEGIN
i := 0;
WHILE i < 30 DO BEGIN
x := i;
CALL fib;
write i;
write r;
i := i + 1;
END
END.