3 ms·
Not thread-safe. Also, from Alex in the comments: "Sounds good! Although probably we will run out of stack waay before that".
by joveian 7y ago
Not thread-safe. Also, from Alex in the comments: "Sounds good! Although probably we will run out of stack waay before that".
- sn 7y agoIt won't run out of stack space with a high enough optimization level so that it uses tail recursion. https://en.wikipedia.org/wiki/Tail_call https://en.wikipedia.org/wiki/Tail_call You can try this yourself by compiling: #include <stdio.h> int i = 0; int x() {--i && x(printf("x"));} int main() {x();} using gcc with and without '-02'.