3 ms·
I'm partial to the lisp style: #include <stdio.h> int loop(int i){ return ((i==0) ?0 :(printf("%d\n",i),loop(i-1)));} int main (void){
by informatimago 10y ago
I'm partial to the lisp style:
#include <stdio.h>
int loop(int i){
return ((i==0)
?0
:(printf("%d\n",i),loop(i-1)));}
int main (void){
return loop(10);}
- Kristine1975 10y agoNice. At least if your compiler implements tail call optimization, otherwise sooner or later you'll get a stack overflow.