You are on page 1of 2

Java Loops II

int result=a;
for(int k=0;k<n;k++){
result=(int)Math.pow(2,k)*b + result;
System.out.print(result+" ");
}
System.out.println();

for(int k=0;k<n;k++)
{ for(int j=0;j<=k;j++)
v=v+a+(b*(2^j));
if(k!=n-1)
System.out.print(v+" ");
else{
System.out.print(v);
}
}System.out.println("\n");
v=0;
}
in.close();
}

int tempAnswer = A;
for (int j = 0; j < loop; j++) {
if (j == 0)
tempAnswer += a;
tempAnswer += (int) (Math.pow(2.0, j) * B);
System.out.print(tempAnswer + " ");
}

public static void doJob(int a, int b, int n){

int result=0;
result = a+result;
for (int i = 0 ;i<n;i++){
result =result + (int)Math.pow(2, i)*b;
System.out.print(result + " ");
}
System.out.println();
}

You might also like