public class MathToolbox { /** This method should return true if and only if the input i is a positive * prime number. A prime is a number which is only divisible by 1 and * itself (however the numbers 0 and 1 are not considered primes). */ public static boolean isPrime(int i) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** This method will return the total number of primes in the range between * lower and upper, including lower and upper themselves. * * Hint: it's possible to use isPrime(int i) as part of the computation. */ public static int numPrimes(int lower, int upper) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Find the factorial of n, which is given by n! = 1*2*...*(n-1)*n. The * factorial of zero is a special case which is equal to 1. */ public static int factorial(int n) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Sums the series 1^p+2^p+...+(n-1)^p+n^p. */ public static double sumPower(int n, double p) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Sums up the elements in list, but only including the elements x in list * for which low <= x <= high. */ public static int boundedSum(int[] list, int low, int high) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Assume that list and filterList are lists of the same length. Then if the * elements in list are l0, l1, ..., l(n-2), l(n-1) and the elements in filterList * are f0, f1, ..., f(n-2), f(n-1), then this method will return * l0*f0+l1*f1+...+l(n-2)*f(n-2)+l(n-1)*f(n-1). */ public static double filteredSum(double[] list, double[] filterList) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Computes the geometric mean of the numbers in list. If the n numbers in * list are l0, l1, ..., l(n-2), l(n-1), then the geometric mean is defined * as the nth root of the product l0*l1*...*l(n-2)*l(n-1). * You may assume that the list is not empty and the numbers are all positive. * * Hint: you may use the built-in Math.pow(). */ public static double geometricMean(double[] list) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Considering the set of differences between consecutive elements in list, * this method returns the largest. Consecutive difference is defined as * the latter element minus the earlier element, i.e. list 1 - list 0. If there * are not enough elements in the list to compute any differences, then the * method should return zero by default. */ public static int largestConsecutiveDiff(int[] list) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** A duplicate element is an element which appears more than once in the list. * This method returns the largest element in list which has any duplicates * whatsoever. If none of the elements have duplicates (every element in the * list is unique) then this method should return Integer.MIN_VALUE. */ public static int largestElementWithDups(int[] list) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } /** Assume that list and freqs are lists of the same size. For each element in list, * this method should count the number of times that elements occurs in the list, * and store the value in the same spot in freqs. * * For example, if list[3] == 4, and the number 4 appears a total of 7 times in list, * then the value 7 should be stored in freqs[3]. The same goes for all elements in * freqs */ public static void findElementFreqs(int[] list, int[] freqs) { // DELETE THE LINE BELOW ONCE YOU IMPLEMENT THE CALL! throw new RuntimeException("not implemented!"); } }