Skip to content

Instantly share code, notes, and snippets.

@yutopp
Created April 5, 2016 00:52
Show Gist options
  • Save yutopp/a96a08b39666fd97a1750e3bde71e645 to your computer and use it in GitHub Desktop.
Save yutopp/a96a08b39666fd97a1750e3bde71e645 to your computer and use it in GitHub Desktop.
import std.stdio;
import std.assert;
def main() {
val a = fib!(40)();
assert( a == 102334155 );
a.print();
}
def fib!(v: int32)(): int32 when v == 0 {
return 0;
}
def fib!(v: int32)(): int32 when v == 1 {
return 1;
}
def fib!(v: int32)(): int32 when v >= 2 {
return fib!(v-1)() + fib!(v-2)();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment