This commit is contained in:
Ingy döt Net 2013-04-10 16:57:12 -07:00
parent 518da4a923
commit 764da6cbbb
6144 changed files with 83610 additions and 11 deletions

View file

@ -0,0 +1,9 @@
uint fib(in uint n) pure nothrow {
immutable self = &__traits(parent, {});
return (n < 2) ? n : self(n - 1) + self(n - 2);
}
void main() {
import std.stdio;
writeln(fib(39));
}

View file

@ -0,0 +1,18 @@
import std.stdio;
int fib(in int n) pure nothrow {
assert(n >= 0);
return (new class {
static int opCall(in int m) pure nothrow {
if (m < 2)
return m;
else
return opCall(m - 1) + opCall(m - 2);
}
})(n);
}
void main() {
writeln(fib(39));
}