TCS
Company
Programming
Functions
In a sequence of integers, A(n) = A(n-1) - A(n-2), where A(n) is the n th term in the sequence, n
is an integer and n >=3, A(1)=1,A(2)=1 . Calculate S(1000), where S(1000) is the sum of the first
1000 terms
a) 1
b) -1
c) 2
d) 0
Read Solution (Total 8)
-
- Let us analyzse the series.
A(3)=A(2)-A(1)=0
A(4)=A(3)-A(2)=-1
A(5)=A(4)-A(3)=-1
A(6)=A(5)-A(4)=0
A(7)=A(6)-A(5)=1
A(8)=A(8)-A(6)=1
So, The series is repeating after every six term.
Also , Sum of all numbers from 1 to 6 is 0.
i.e S(6)=0.
Similarly , S(12),S(18),S(24), all are zero.
So,the sum is zero when number is divisible by 6.
Now, We have n=1000
Now,1000 mod 6 =4.
So S(1000)=S(4).
S(1000)=S(4)=S(1)+S(2)+S(3)+S(4)
=>S(1000)=1+1+0+(-1)
Therefore, S(1000) = 1.
- 9 years agoHelpfull: Yes(29) No(0)
- 0 is the answer.
- 9 years agoHelpfull: Yes(10) No(5)
- The Sequence repeats after 6 terms (i.e 1,1,0,-1,-1,0...so on) So if we calculate 1000 mod 6 we get 4 as the remainder.
S(1000) = S(4) = A(1)+A(2)+A(3)+A(4) = 1 + 1 + 0 - 1 = 1 - 9 years agoHelpfull: Yes(7) No(0)
- 1
bcoz value of A(1)=1 is repeating after every 6th term i.e. A(7)=1 therefore S(6)=0
hence if we divide 1000 by 6 then reminder will be 4 n hence S(996)=0
n sum remaining 4 terms is 1(1+1+0+(-1)=1) S(1000)=1 - 9 years agoHelpfull: Yes(1) No(0)
- Sequence Follows
1,1,0,-1,-1,0,1,1,0,-1,-1,..........
Sum of First 5 terms is 0
Answer is 0
Option (d) - 9 years agoHelpfull: Yes(0) No(4)
- 1 is the answer.
s(1000)=A(1)+A(2)+A(3)+.....A(1000).
Leave A(1), A(2) behind since values known.
A(3) =A(2)-A(1)
A(4)=A(3)-A(2)
A(5)=A(4)-A(3)
..........................
A(1000) = A(999)-A(998)
.....
As you can see each term first after equaltity gets cancelled with second term in the next equality. Hence all except A(999) and A(1) remains
which implies : s(1000) = A(1)+ A(2) + A(999) - A(1)
= A(999) + 1
Now, A(999) = A(998) -A(997)
=A(997)-A(996)-A(997)
=-A(996)
Similary for every three difference this cycle repeats which means it occurs 329 times. After which it will be A(3) which is 0
s(1000)=0+1=1 - 9 years agoHelpfull: Yes(0) No(0)
- 0 ans ascalcultd
- 9 years agoHelpfull: Yes(0) No(2)
- given A(1)=A(2)=1
A(3)=A(2)-A(1)=1-1=0
A(4)=A(3)-A(2)=0-1=-1
A(5)=A(4)-A(3)=-1-0=-1
A(6)=A(5)-A(4)=-1-(-1)=0
!
.
.
.
Series coming is 1,1,0,-1,-1,0,1,1,0.........see adding we get zero only so, answer is zero(0). - 9 years agoHelpfull: Yes(0) No(3)
TCS Other Question