7
14 15
28 29 30 31
56 57 58 59 60 61 62 63
This is the way in which I want to print but couldn't. The code I have written is like:
public class Numbers
{
public void printseries(int a, int b)
{
for (int i = 1; i <= 2 * b; )
{
int k = 0;
k = a * i;
i *= 2;
for (int j = 1; j < i; j *= 2)
{
if (j == 1)
System.out.print(k);
else
{
k++;
System.out.print(k);
}
}
}
}
}
It prints the following
7141528293056575859