[gesamt] Added ag/codea/codeb testcases
[testub10.git] / gesamt / codeb_georg_fib_044.0
diff --git a/gesamt/codeb_georg_fib_044.0 b/gesamt/codeb_georg_fib_044.0
new file mode 100644 (file)
index 0000000..c8e1a16
--- /dev/null
@@ -0,0 +1,24 @@
+/* fibonacci */
+
+/* F_0 = 0 */
+/* F_1 = 1 */
+/* F_n = F_{n-1} + F_{n-2} */
+
+struct a b c end;
+
+method fib(x)
+       if x < 0 then return x; end;
+       a := 0;
+       if x < 1 then return x; end;
+       b := 1;
+       if x < 2 then return x; end;
+       var t := this;
+
+       while not (x < 2)
+       do
+               t.c := t.a-(0-t.b);
+               t := t--8;
+               x := x-1;
+       end;
+       return (t-8).c;
+end;