RosettaCodeData/Task/Man-or-boy-test/D/man-or-boy-test-1.d
2023-07-01 13:44:08 -04:00

14 lines
327 B
D

import core.stdc.stdio: printf;
int a(int k, const lazy int x1, const lazy int x2, const lazy int x3,
const lazy int x4, const lazy int x5) pure {
int b() {
k--;
return a(k, b(), x1, x2, x3, x4);
}
return k <= 0 ? x4 + x5 : b();
}
void main() {
printf("%d\n", a(10, 1, -1, -1, 1, 0));
}