1. Write the method dividesSomeElement(int num, ArrayList<Integer> al) which returns true if num divides any element in al. The ArrayList<Integer> could be empty.
Example:
ArrayList<Integer> alist = new ArrayList<Integer>(); alist.add(2); alist.add(3); alist.add(5); System.out.println(dividesSomeElement(22, alist)); // prints true System.out.println(dividesSomeElement(13, alist)); // prints false
2. Using the method dividesSomeElement that you wrote in problem (1), write the method primesUpTo(int num) that returns an ArrayList<Integer> containing all prime numbers up to and including num.
Example:
System.out.println(primesUpTo(20)); // prints [2, 3, 5, 7, 11, 13, 17, 19] System.out.println(primesUpTo(11)); // prints [2, 3, 5, 7, 11] System.out.println(primesUpTo(1)); // prints []