RosettaCodeData/Task/Mutual-recursion/D/mutual-recursion.d

15 lines
285 B
D
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
import std.stdio, std.algorithm, std.range;
2014-04-02 16:56:35 +00:00
int male(in int n) pure nothrow {
return n ? n - male(n - 1).female : 0;
2013-04-10 21:29:02 -07:00
}
2014-04-02 16:56:35 +00:00
int female(in int n) pure nothrow {
return n ? n - female(n - 1).male : 1;
2013-04-10 21:29:02 -07:00
}
void main() {
2014-04-02 16:56:35 +00:00
20.iota.map!female.writeln;
20.iota.map!male.writeln;
2013-04-10 21:29:02 -07:00
}