You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
public class doubleTest {
public static void main(String[] args) { System.out.println(containsMultipleOf(new int[] {}, 2)); System.out.println(containsMultipleOf(new int[] { 1, 1, 1 }, 2)); System.out.println(containsMultipleOf(new int[] { 1, 1, 3 }, 3)); System.out.println(containsMultipleOf(new int[] { -1, -2, -3 }, 1)); }
public static boolean containsMultipleOf(int[] x, int base) { int counter = 0; for (int i = 0; i < x.length; i++) { if (x[i] / base != 0) { counter++; } } if (counter > 0) { return true; } else { return false; } } }
|