GeeksforGeeks » Interview Questions

what is the output of this recursion func

(2 posts)
[closed]
  1. angel
    guest
    Posted 8 months ago #

    int fun(int a, int b)
    {
       if (b == 0)
           return 0;
       if (b % 2 == 0)
           return fun(a+a, b/2);
    
       return fun(a+a, b/2) + a;
    }
    
    int main()
    {
      printf("%d", fun(4, 3));
      getchar();
      return 0;
    }
  2. kartik
    Moderator
    Posted 8 months ago #


Topic Closed

This topic has been closed to new replies.

RSS feed for this topic