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