Computer Sciences > GATE 2026 SET-1 > Recursion
Consider the recursive functions represented by the following code segment:
int bar(int n){
if (n == 1) return 0;
else return 1 + bar(n/2);
}
int foo(int n){
if (n == 1) return 1;
else return 1 + foo(bar(n));
}

The smallest positive integer n for which foo(n) returns 5 is ______. (answer in integer)
Note: Ignore syntax errors (if any) in the function.

Correct : 65536

Similar Questions

Consider the following C program: #include<stdio.h> int r(){     int static num=7;     return num--; } int main() {     for...
#239 MCQ
Consider the following C program: void convert(int n) { &nbsp; &nbsp; if (n < 0) &nbsp; &nbsp; printf(β€œ % d”, n); &nbsp; &nbsp; else { &nbs...
#241 MCQ
Consider the following C function. int fun (int n) { &nbsp; &nbsp; int x=1, k; &nbsp; &nbsp; if (n==1) return x; &nbsp; &nbsp; for (k=1; k < n; ++k) &...
#527 Fill in the Blanks

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......