X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=testub10.git;a=blobdiff_plain;f=gesamt%2Fcodeb_georg_fib_044.0;fp=gesamt%2Fcodeb_georg_fib_044.0;h=c8e1a16401da530dcb9653ce88fc6e8045e4c11f;hp=0000000000000000000000000000000000000000;hb=029401d51612c5e69d7ac8603e1b69cd7ed6ef96;hpb=bf19094ac2573112418701ba4c6abf5779e3a9f7 diff --git a/gesamt/codeb_georg_fib_044.0 b/gesamt/codeb_georg_fib_044.0 new file mode 100644 index 0000000..c8e1a16 --- /dev/null +++ b/gesamt/codeb_georg_fib_044.0 @@ -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;