f(20,1)----->f(10,2)-1-----> f(5,4)-2 ------------->f(2,8) +4 ----->
f(1,16)-8 -----> f(0,32) +16----->return 0
               10-1=9 <--------  12-2=10 <--------- 8+4=12<-------- 16-8=8
<--------  0+16     <---------     -




*Muthuraj R.
4TH Year BE.**
Information Science Dept*
*PESIT, Bengaluru .
*




On Mon, Jul 25, 2011 at 8:48 AM, Vijay Khandar <[email protected]>wrote:

> #include<stdio.h>
> #include<conio.h>
> int f(int n,int k)
> {
> if (n==0)
> return 0;
> else
>  if(n%2)
>  return f(n/2,2*k)+k;
>  else return f(n/2,2*k)-k;
> }
> int main()
> {
> clrscr();
> printf("\n %d",f(20,1));
> getch();
> }
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to