We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

You need to take the value of a, b and n and create a series of ans using this (a + 2^0 * b),..., (a + 2^0 * b + 2^n-1 * b)

q is just tells the number of quires you'll be performing,
if q is 3 then you'll have to create 3 sereies of ans using the series that they have given you.

q = 3;

a = 0 b = 2 n = 10

a = 5 b = 3 n = 5

a = 1 b = 8 n = 3

[2, 6,..., 2046]

[8, 14,...,98]

[9, 25, 57]

n will tell you how long will series of ans will be.
a = 0; b = 2 ; n = 10;
(0 + 2^0 * b), [(0 + 2^0 * b) + (2^1 * b)] ... (0 + 2^0 * b + 2^1 * b + a + 2^0 * b )
Your series of ans be [2 , 6 ... ans]

The catch in the series is you only need to add the new 2^n-1 to the previous calculation you did.

This program is working fine, but constant value =0 you defined already right?
If count !=0 then, constant will become 0*2 =0 and it will continue right? can u please explain how it is working.

## Java Loops II

You are viewing a single comment's thread. Return to all comments →

You need to take the value of a, b and n and create a series of ans using this (a + 2^0 * b),..., (a + 2^0 * b + 2^n-1 * b)

q is just tells the number of quires you'll be performing, if q is 3 then you'll have to create 3 sereies of ans using the series that they have given you.

q = 3;

a = 0 b = 2 n = 10

a = 5 b = 3 n = 5

a = 1 b = 8 n = 3

[2, 6,..., 2046]

[8, 14,...,98]

[9, 25, 57]

n will tell you how long will series of ans will be. a = 0; b = 2 ; n = 10; (0 + 2^0 * b), [(0 + 2^0 * b) + (2^1 * b)] ... (0 + 2^0 * b + 2^1 * b + a + 2^0 * b ) Your series of ans be [2 , 6 ... ans]

The catch in the series is you only need to add the new 2^n-1 to the previous calculation you did.

This program is working fine, but constant value =0 you defined already right? If count !=0 then, constant will become 0*2 =0 and it will continue right? can u please explain how it is working.

the value of constanst is 1 after first execution

this code almost correct, i try this code but the result is one excess, how to fix it ?