Question: You may not use any built-in functionality for copying an array, like System.arrayCopy(), Arrays.copyOf(), Object.clone(), Arrays.stream, etc. If you want to copy an array, you

You may not use any built-in functionality for copying an array, like System.arrayCopy(), Arrays.copyOf(), Object.clone(), Arrays.stream, etc. If you want to copy an array, you should do it manually (i.e. create a new array and transfer the data).

A prime number is only divisible by 1 and itself, while composite numbers have three or more divisors. When a number has "a lot" of divisors, such as 12 or 360, we might want to identify them as "highly composite". Since larger numbers have more chances for divisors, we need a definition that acknowledges this, so we use the following:

A positive integer X is highly composite if every positive integer lower than it has fewer divisors than X.

You can think of this as walking the number line from 1 upwards, and each time you reach a new high score of number of divisors, you've identified a highly composite number. This chart may help:

value of n 1 2 3 4 5 6 7 8 9 10 11 12 13
number of divisors 1 2 2 3 2 4 2 4 3 4 2 6 2
most seen so far 1 2 2 3 3 4 4 4 4 4 4 6 6
who had that # divs first? 1 2 2 4 4 6 6 6 6 6 6 12 12
highly composite? Y Y N Y N Y N N N N N Y N

Create the following two methods:

public static int numDivisors(int num)

It returns how many divisors num has or -1 when num is not a positive integer.

public static boolean highlyComposite(int num)

Given a positive integer num (no need for validation), it returns true or false accordingly. This method must call numDivisors; you will lose points if you repeat functionality that was already built for numDivisors.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!