c - time Complexity in Recursion -


i need code..how can improve time complexity of following recursion? need remove recursion @ all? because in case code giving variable results when trying for/while loop.

#include<stdio.h> int one=0,zero=0; void reco(int n) {     if(n<=0)     {         zero++;         return;     }     if(n==1)     {         one++;         return;     }     reco(n-1);     reco(n-2);     reco(n-3);     return;  } main() {   int n;     scanf("%d", &n);     reco(n);     printf("%d %d",one,zero);     return; }  

input:7 output: 24 33


Comments