Computer Sciences > GATE 2026 SET-1 > Recursion
Consider the recursive functions represented by the following code segment:
The smallest positive integer n for which
Note: Ignore syntax errors (if any) in the function.
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...
Consider the following C program:
void convert(int n) {
if (n < 0)
printf(β % dβ, n);
else {
&nbs...
Consider the following C function.
int fun (int n)
{
int x=1, k;
if (n==1) return x;
for (k=1; k < n; ++k)
&...
Total Unique Visitors
Loading......