codeb fibonacci testfaelle
[testub10.git] / codeb / georg_fib_025.0
diff --git a/codeb/georg_fib_025.0 b/codeb/georg_fib_025.0
new file mode 100644 (file)
index 0000000..673e43c
--- /dev/null
@@ -0,0 +1,19 @@
+/* fibonacci */
+
+/* F_0 = 0 */
+/* F_1 = 1 */
+/* F_n = F_{n-1} + F_{n-2} */
+
+method fib(x)
+       var a := 0;
+       var b := 1;
+       if x < 2 then return x; end;
+       while not (x < 2)
+       do
+               var A := a;
+               a := b;
+               b := A-(0-b);
+               x := x-1;
+       end;
+       return b;
+end;