TCS
Company
if g(0)=1, G(1)=-1 and G(N)=G(N-1)+G(N-2) then g(5)=?
Read Solution (Total 4)
-
- g(0)=1
g(1)=-1
g(2)=g(1)+g(0) = -1 + 1 = 0
g(3) = g(2) + g(1) = 0 -1 = -1
g(4) = g(3) + g(2) = -1 + 0 = -1
g(5)= g(4) + g(3) = -1 + -1 = -2 - 12 years agoHelpfull: Yes(35) No(3)
- g(0)=1
g(1)=-1
g(2)=g(1)-g(0)=-1-1=-2
g(3)=g(2)-g(1)=-2-(-1)=-1
g(4)=g(3)-g(2)=-1+2=1
thus, g(5)=g(4)-g(3)=1-(-1)=2
ans=2. - 12 years agoHelpfull: Yes(7) No(11)
- sorry i took g(n)=g(n-1)-g(n-2)instead of g(n)=g(n-1)+g(n-2)
- 12 years agoHelpfull: Yes(5) No(1)
- -2
g(5)=g(4)+g(3)
=g(3)+g(2)+g(2)+g(1)
=g(2)+g(1)+2(g(1)+g(0))+g(1)
=3(g(1)+g(0))+2g(1)
=3(1-1)+2(-1)
=-2 - 12 years agoHelpfull: Yes(1) No(1)
TCS Other Question