View Single Post
  #6   Spotlight this post!  
Unread 15-02-2007, 13:49
Salik Syed Salik Syed is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Stanford CA.
Posts: 514
Salik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud of
Send a message via AIM to Salik Syed
Re: RAndom C++ Problem

Code:
int fib(int number)
{
if(number==0 || number ==1) return number;
else return fib(number-1)+fib(number-2);
}
yay.
User enters a term, it spits out the fib value for that term.
Look at the inductive definition of Fibonacci series if you want to see why this works
It runs in N*N time though.There are alot of clever optimizations that can be done to make this faster.
__________________
Team 701