FunctionsFTW/Fibonacci

From Esolang
Jump to navigation Jump to search
Back to FunctionsFTW
setNum("stl", 1);                                        "Set stl(second to last) to 1";
setNum("last", 0);                                       "Set last to 0";

label("l");
print(numToStr(add(getNum("stl"), getNum("last"))));     "Print stl + last";
setNum("last", add(getNum("stl"), getNum("last")));      "last = stl + last";
setNum("stl", add(getNum("last"), neg(getNum("stl"))));  "stl = (stl + last) - stl = last";
goto("l");                                               "Repeat";

Minimized (182 bytes)

setNum("s",1);setNum("l",0);label("L");print(numToStr(add(getNum("s"),getNum("l"))));setNum("l",add(getNum("s"),getNum("l")));setNum("s",add(getNum("l"),neg(getNum("s"))));goto("L");