If given int array A is [1,0,0,1,1] =9 A[i]*(-2)^i (^ power). How to write a java program get the int array sequence for give integer.
Asked
Active
Viewed 559 times
1 Answers
1
public class A {
public static void main(String[] args) {
int [] arr = {1,0,0,1,1};
for (int i = 0; i < arr.length; i++) {
arr[i]=9*arr[i]*(int)Math.pow(-2,i);
}
} System.out.println(Arrays.toString(arr));
}

Racil Hilan
- 24,690
- 13
- 50
- 55

user5314031
- 11
- 1
-
I wonted to convert to integer to binary not the binary to integer – Dinusha Sep 09 '15 at 03:49