[gesamt] Added ag/codea/codeb testcases
[testub10.git] / gesamt / codeb_georg_fib_042.0
diff --git a/gesamt/codeb_georg_fib_042.0 b/gesamt/codeb_georg_fib_042.0
new file mode 100644 (file)
index 0000000..96c17d7
--- /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 := f0-(0-f1);
+       if x < 3 then return f2; end;   f3 := f1-(0-f2);
+       if x < 4 then return f3; end;   f4 := f2-(0-f3);
+       if x < 5 then return f4; end;   f5 := f3-(0-f4);
+       if x < 6 then return f5; end;   f6 := f4-(0-f5);
+       if x < 7 then return f6; end;   f7 := f5-(0-f6);
+       if x < 8 then return f7; end;   f8 := f6-(0-f7);
+       if x < 9 then return f8; end;   f9 := f7-(0-f8);
+       return f9;
+end;