GeeksforGeeks » Interview Questions
Goldman Sachs Interview Question for Software Engineer/Developer (Fresher)
(7 posts)-
You have 4218 no of balls. put 1 balls at top layer 3 at 2nd top layer then 6 and then 10 ... Continue in this way. How many layers are possible.?
-
for n =1, value is 1 , nth term = (n-1) th term + n for n >1
-
f(1) = 1 , f(n) = f(n-1) + n , so summation of f(n) = 4218
f(n) + f(n-1) + f(n-2) + + 10 + 6 + 3 + 1 = 4218
n + f(n-1) + f(n-2) + n - 1 + f(n-3) + n - 2 + ...................+ 10 + 6 + 3 + 1 = 4218 -
i am not sure how to solve it ..
wrote a program and answer is 91
-
a(n)=(n*(n+1))/2
-
Answer is 28
Number of balls at i'th level is "num ==> i*(i+1)/2" ...
(If we generate this series this series is called series of triangular numbers)
(i.e. series 1,3,6,10,15,... is called series of triangular numbers)
then sum of balls before (& including) i'th level = i*(i+1)*(i+2)/6
(This is the standard expression for the summation of Triangular numbers)Pure maths follows now:
We must have :
i*(i+1)*(i+2)/6 <= 4218
i^3 + 3*(i^2) + 2*i - (4218*6) = 0 (Considering equality only to make it clearer)
Solving this 3rd degree equation we get "i = 28.37"
We need greatest integer number less than this...(remember '<' sign that we dropped above)
which is nothing but 28. -
Hi
You can find this info by using search box in the top of website with some keywords related before posting questions.
Reply
You must log in to post.