Thanks Muthuraj....I got it...... On Mon, Jul 25, 2011 at 9:42 PM, sameer.mut...@gmail.com < sameer.mut...@gmail.com> wrote:
> 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 <vijaykhand...@gmail.com>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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.