From 2cab92f584feb30127a512d164ff49ced88339e0 Mon Sep 17 00:00:00 2001 From: Alexander Wehde Date: Tue, 26 Apr 2022 11:18:02 +0200 Subject: [PATCH] added DoubleTest.java --- doubleTest.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doubleTest.java diff --git a/doubleTest.java b/doubleTest.java new file mode 100644 index 0000000..af5c309 --- /dev/null +++ b/doubleTest.java @@ -0,0 +1,23 @@ +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; + } + } +} \ No newline at end of file