The following function Recur is a part of some class. What will be the output of the function Recur() when the value of n is equal to 10. Show the dry run/working
void Recur(int n)
{
if (n>1)
{
System.out.print(n+ " ");
if (n%2 !=0)
{
n=3*n+1;
System.out.print(n + " ");
}
Recur (n/2);
}
}
Recur(10)
10 Recur(5)
5 Recur(10)
16 Recur(8)
8 Recur(4)
4 Recur(2)
2 Recur(1)
10 5 16 8 4 2