[ create a new paste ] login | about

Link: http://codepad.org/8GtKswm8    [ raw code | output | fork ]

D, pasted on Nov 26:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import std.c.stdio: printf;

int a(int k, lazy int x1, lazy int x2, lazy int x3, lazy int x4, lazy int x5) {
    int b() {
        k -= 1;
        return a(k, b(), x1, x2, x3, x4);
    };

    return k <= 0 ? x4 + x5 : b();
}

void main() {
    printf("%d\n", a(21, 1, -1, -1, 1, 0));
}


Output:
1
-389695


Create a new paste based on this one


Comments: