Re: [algogeeks] Re: Needed recursive sol
@rahul tiwari..i have that soln...i think u cnt get questionhw do we knw the number of terms?/ On Sun, Oct 2, 2011 at 2:09 PM, Rahul Tiwari rahultiwari6...@gmail.comwrote: working code : #includestdio.h int fib(int n) { if(n==1) return 0; if(n==2) return 1; return fib(n-1)+fib(n-2); } int main() { int n,i,sum=0; printf(enter no of terms\t ); scanf(%d,n); printf(fibonacci series = \t ); for(i=1;i=n;i++) { printf(%d\t,fib(i)); sum+=fib(i); } printf(\nsum upto %d terms = %d\n,n,sum); return 0; } rahul -- 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.
Re: [algogeeks] Re: Needed recursive sol
gr 8 soln...thnx 2011/10/2 akanksha akanksha.271...@gmail.com int sum(int f0,int f1) { if(f1=1000) { int x= sum(f1,f0+f1); if(f1%2==0) x+=f1; return x; } else return 0; } -- 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.
Re: [algogeeks] Re: Needed recursive sol
there must be a non brute force approach too rite??? -- 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.
Re: [algogeeks] Re: Needed recursive sol
yea...first sol is brute force...but this is not..that is posted by akanshai think...but not sure...the question wants only recursivehoope sumone may come with sumthng new On Sun, Oct 2, 2011 at 10:35 AM, Siddhartha Banerjee thefourrup...@gmail.com wrote: there must be a non brute force approach too rite??? -- 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.
Re: [algogeeks] Re: Needed recursive sol
this is bruteforce. You are calculating all fib. numbers. On Sun, Oct 2, 2011 at 10:38 AM, rahul sharma rahul23111...@gmail.comwrote: yea...first sol is brute force...but this is not..that is posted by akanshai think...but not sure...the question wants only recursivehoope sumone may come with sumthng new On Sun, Oct 2, 2011 at 10:35 AM, Siddhartha Banerjee thefourrup...@gmail.com wrote: there must be a non brute force approach too rite??? -- 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. -- 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.
Re: [algogeeks] Re: Needed recursive sol
Using Wladimir's formulas, you have: F(0) + F(1) + F(2) + F(3) + F(4) + F(5) + F(6) + ... + F(3n-2) + F(3n-1) + F(3n) = F(3n+2) - 1 F(0) +(F(1) + F(2))+ F(3) +(F(4) + F(5))+ F(6) + ... +(F(3n-2) + F(3n-1))+ F(3n) = F(3n+2) - 1 F(0) + 2F(3) + 2F(6) + ... + 2F(3n) = F(3n+2) - 1 Since F(0) = 0, F(0) + F(3) + F(6) + ... + F(3n) = (F(3n+2) - 1)/2 Marcelo Menegali On Sun, Oct 2, 2011 at 2:10 AM, shady sinv...@gmail.com wrote: this is bruteforce. You are calculating all fib. numbers. On Sun, Oct 2, 2011 at 10:38 AM, rahul sharma rahul23111...@gmail.comwrote: yea...first sol is brute force...but this is not..that is posted by akanshai think...but not sure...the question wants only recursivehoope sumone may come with sumthng new On Sun, Oct 2, 2011 at 10:35 AM, Siddhartha Banerjee thefourrup...@gmail.com wrote: there must be a non brute force approach too rite??? -- 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. -- 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.