In: Computer Science
you are givena pair (a,b) .after eatch unit of time
pair(a,b)
getd changeed to (b-a,b+a).you are given the initial value of
pair and an integer n and you have to print the value of the pair
at the nth unit of time
here we consider the time to be starting from t=0
so at t=0 we have
at
we have
now following the same pattern and making the first value as
first value = second value - first value
and second value as
second value = second value + first value
we get
at t=2 we have
now following same pattern we have at
t=3
at
we have
so from this we can see that at every even position we are
getting
and at every odd position we are getting
here we take the base case for t=0 and t=1 to be
respectively as it is given in question
so final anwer would be the following relation
ans= (a,b) if n=0
(b-a,b+a) if n =1
(n*a, n*b) if(n>0 and n is even)
( (n-1)*(b-a),(n-1)*(b+a)) (if n>1 and n is odd)