Part 3a. Largest power of two less than (10 pts) Implement the method public static int largestPow2LessThan(int n) which calculates and returns the largest integer power of 2 less than n. You may assume n is greater than 1. For example, if n is 10, the largest power of 2 less than n is 8 (8 is 2 cubed). If n is 8, the answer is 4. If n is 2, 20

Answer :

temmydbrain

Answer:

Check the explanation

Explanation:

========================================================================

// Part 3 (a)

public static int largestPow2LessThan(int n) {

   int two = 1;

   while (two * 2 < n) {

       two *= 2;

   }

   return two;

}

================================================================

Other Questions