If G(0) = -1 G(1)= 1 and G(N)=G(N-1) - G(N-2) then what is the value of G(6)?If anyone know the answer for this question pls tell me with explanation

This question is related to TCS Interview

Showing Answers 1 - 24 of 24 Answers

sandhya

  • Oct 21st, 2006
 

ans: -1

bcoz g(2)=g(1)-g(0)=1+1=2

g(3)=1

g(4)=-1

g(5)=-2

g(6)=-1

  Was this answer useful?  Yes

ravikumar

  • Oct 22nd, 2006
 

 HI,sandya ur anser is exactly correct.

  Was this answer useful?  Yes

Abhishek Sharma

  • Oct 24th, 2006
 

Given:-G(0)=-1,--------------1

          G(1)=1,---------------2

          G(N)=G(N-1)-G(N-2)------3

To Find:-G(6)

Solution:-Substitue N=2 in 3 We get

              G(2)=G(1)-G(0)

          =>G(2)=1-(-1)

         =>G(2)=2------------4

         now substitute N=3 in 3

         G(3)=G(2)-G(1)

         G(3)=2-1

         G(3)=1

now put N=4 in 3

G(4)=G(3)-G(2)

G(4)=1-2=-1

not put N=5 in 3

G(5)=G(4)-G(3)

G(5)=(-1)-1= -2

now finally put N=6 in 3

G(6)=G(5)-G(4)

G(6)=-2-(-1)=-1

Hence G(6)=-1

         

          

              

 

 

  Was this answer useful?  Yes

javasaji

  • Dec 29th, 2006
 

it is very easy...

if g(1)=0,and g(0)=-1

then g(2)=g(1)-g(0)=1-(-1)=2,

so g(3)=1

         g(4)=-1

         g(5)=-2

 and the result g(6)=-1

  Was this answer useful?  Yes

gaurang damley

  • Jan 17th, 2007
 

your ans will be -1

G(2)=2

G(3)=1

G(4)=-1

G(5)=-2

G(6)=-1

  Was this answer useful?  Yes

S.Seenivasan @SVCE

  • Jan 20th, 2007
 

    G(6) = G(5) - G(4)
             = G(4) - G(3) - G(4)
             = -G(3)
             = -(G(2) - G(1))
             = -(G(1) - G(0) - G(1))
             = -G(0)
BUT G(0) = -1 WHICH IMPLIES THAT G(6) = -(-1) = +1
The answer is +1........

  Was this answer useful?  Yes

sankar

  • Jan 25th, 2007
 

ans g(6)=1if G(0)=-1 G(1)=1 and G(N-1)-G(N-2) G(6-1)-G(6-2) G(6)=1

  Was this answer useful?  Yes

girish

  • Feb 3rd, 2007
 

shankar u did wrong in the last stepits -(-G(0)) G(0)=-1 and not +1

  Was this answer useful?  Yes

atul.m

  • Feb 6th, 2007
 

shreenivasan..in ur sixth step the value will be as follows= - ( - G(0)) which is = G(0) and therefore the final answer will be -1.

  Was this answer useful?  Yes

rajkumar

  • Mar 4th, 2007
 

g6=g5-g4              .......g5=g4-g3
g6=g4-g3-g4=-g3 .......g3=g2-g1
g6=-g2+g1
g6=-g1+g0+g1
g6=g0=-1

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions