From 17d6f50904caf8d1557ad89d69add8dc2945492c Mon Sep 17 00:00:00 2001 From: Scarlett Date: Tue, 6 May 2025 19:21:35 -0400 Subject: [PATCH] fib --- tests/programs/fib.alpha | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/tests/programs/fib.alpha b/tests/programs/fib.alpha index bbc20f9..287614b 100644 --- a/tests/programs/fib.alpha +++ b/tests/programs/fib.alpha @@ -4,36 +4,20 @@ function entry : string2integer function fib : integer2integer fib(i) := { - [ integer: a; integer: b; integer: count ] - - a := 1; - b := 2; - if (i = 0) then { + if (i < 1) then { return 0; } else { - a := a; + i := i; } - if (i = 1) then { - return 1; + if (i < 2) then { + return i; } else { - a := a; + i := i; } - if (i = 2) then { - return 2; - } else { - a := a; - } - - count := 2; - while (count < i) { - - count := count + 1; - } - - return b; + return fib(i-1) + fib(i-2); } entry (arg) := {