[gesamt] Added ag/codea/codeb testcases
[testub10.git] / gesamt / codeb_georg_fib_041.0
diff --git a/gesamt/codeb_georg_fib_041.0 b/gesamt/codeb_georg_fib_041.0
new file mode 100644 (file)
index 0000000..1daf7d1
--- /dev/null
@@ -0,0 +1,21 @@
+/* fibonacci */
+
+/* F_0 = 0 */
+/* F_1 = 1 */
+/* F_n = F_{n-1} + F_{n-2} */
+
+struct f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 end;
+
+method fib(x)
+       if x < 0 then return -1; end;   f0 :=  0;
+       if x < 1 then return f0; end;   f1 :=  1;
+       if x < 2 then return f1; end;   f2 :=  1;
+       if x < 3 then return f2; end;   f3 :=  2;
+       if x < 4 then return f3; end;   f4 :=  3;
+       if x < 5 then return f4; end;   f5 :=  5;
+       if x < 6 then return f5; end;   f6 :=  8;
+       if x < 7 then return f6; end;   f7 := 13;
+       if x < 8 then return f7; end;   f8 := 21;
+       if x < 9 then return f8; end;   f9 := 34;
+       return f9;
+end;