Originally Posted by
Salem
Show us what you have so far.
first recursive solution
Code:
int divide(int a)
{
if (a > 1) {
return divide (a/2);
}
return a;
}
second equivalent solution by for loop approach :
Code:
int divide(int a)
{
for( ; a > 1 ; a /=2 );
return a;
}
both solutions are equivalent and this what I reached so far.