You are viewing a single comment's thread. Return to all comments →
Will you tell me the Code how it solved.
for (int j = 0; j < n; j++)
a += b;
System.out.print(a + " ");
b *= 2;
Thanks for sharing, found it very simple to understand.
Not sure why it's been down voted. It's a brilliant solution. Helped me a lot to understand what's going on. Thanks mate
Out of all the complicated solutions, you gave the simplest solution ever.
Brilliant thinking! Thanks for sharing.
I am glad my comment helped you ! Keep Coding :D
really you make it very simple...too good
i didnt understand your logic can u explain it please
i mean first you have to calculate the first term then see that the first term is common in all terms so you have to just appy a loop after that , and in that loop i have told that what we have to perform. Now just simply iterate that loop and multilpy that first term to the matter that you calculated inside the loop.
I've made a "local" class similar to pow... XD
(And completed the test)
But... omg your answer were soo simple and efficient...
This is the best. I was using Math.pow unnecessarily.
good logic but it's is not working giving some runtime exception .
i just want to know that how does your power increments for 2 in this code
look at this
but in that case we would get a space after the last element.
but accroding to test case (given) we should not get a space after last element.
so how can you modify without getting a space at end the end in your code
you can run and check, if in test case space is not allowed after last element you can add space till n-1 length and skip for other.
thanks for helping us.