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.

22 lines
624 B

  1. public class doubleTest {
  2. public static void main(String[] args) {
  3. System.out.println(containsMultipleOf(new int[] {}, 2));
  4. System.out.println(containsMultipleOf(new int[] { 1, 1, 1 }, 2));
  5. System.out.println(containsMultipleOf(new int[] { 1, 1, 3 }, 3));
  6. System.out.println(containsMultipleOf(new int[] { -1, -2, -3 }, 1));
  7. }
  8. public static boolean containsMultipleOf(int[] x, int base) {
  9. int counter = 0;
  10. for (int i = 0; i < x.length; i++) {
  11. if (x[i] / base != 0) {
  12. counter++;
  13. }
  14. }
  15. if (counter > 0) {
  16. return true;
  17. } else {
  18. return false;
  19. }
  20. }
  21. }