Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Algorithms | Recursion | Question 9

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article




#include<stdio.h>
void crazy(int n,int a,int b)
{
    if (n <= 0)  return;
    crazy(n-1, a, b+n);
    printf("%d %d %d\n",n,a,b);
    crazy(n-1, b, a+n);
}
  
int main()
{
    crazy(3,4,5);
    return 0;
}

(A)

1 4 10
2 4 8
1 8 6
3 4 5
1 5 9
2 5 7
1 7 7

(B)

3 4 5
1 4 10
2 4 8
1 8 6
1 5 9
2 5 7
1 7 7

(C)

1 4 10
2 4 8
1 8 6
3 4 5

(D)

3 4 5
1 5 9
2 5 7
1 7 7


Answer: (A)

Explanation:

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads