GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Placement Papers  >  TCS

 Print  |  
Question:  given g(0)=1,g(1)=-1and g(n)=g(n-1)+g(n-2),find(6).



February 02, 2008 18:45:43 #3
 vigneshkumar1988   Member Since: February 2008    Total Comments: 4 

RE: given g(0)=1,g(1)=-1and g(n)=g(n-1)+g(n-2),find(6).
 
g(6)=g(5)+g(4)
now we dont know about g(5),g(4)
g(5)=g(4)+g(3)
g(4)=g(3)+g(2)
g(3)=g(2)+g(1)
g(2)=G(1)+g(0)

now on solving,
    g(2)=-1
    g(3)=-2
    g(4)=-3
g(5)=-5
g(6)=-8
     

 

Back To Question