You are viewing a single comment's thread. Return to all comments →
it's a simple ques. you just need to print the series.
look at series..
scan num=a and add 2^n.b and print..
how i can increment the number 'n' value for getting the series, i dont know how to put loop for this, can anyone plz help me
Just keep on trying, the answer will come up, my algorithm was something like this
create a "cumulative" variable and set it equal to user input "a"
Inside the INPUT FOR Loop
1)Create a new for loop for a variable say "j", start it from 0 to n where n is the input provided by user and already written in the code.
2)compute the part of (2^j)*b and store it in a variable say "res".
3) Now simply add the equation to the cumulative variable -> cumulative=cumulative+res(refer step 2)
4) Print (cumulative+" ")
5) Close for loop
6) user proper Println syntax tomove cursor to next line.
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.
same with me
but it doesn't pass through all the test cases.