Java: Returns the largest integer but not larger than the base-2 logarithm of a specified integer
Largest Integer Base-2 Logarithm
Write a Java program that returns the largest integer but not larger than the base-2 logarithm of a given integer.
Original Number: 2350
Result: 11
Sample Solution:
Java Code:
Sample Output: Original Number: 2350 Result: 11
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to find the smallest integer not less than the base-2 logarithm of a given number.
- Write a Java program to compute the floor of the base-2 logarithm using a recursive approach.
- Write a Java program to calculate the floor of the logarithm of a number for an arbitrary base without built-in functions.
- Write a Java program to compute the floor of the base-2 logarithm without using any math library methods.
Java Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Java program to print an array after changing the rows and columns of a given two-dimensional array.
Next: Write a Java program to prove that Euclid’s algorithm computes the greatest common divisor of two positive given integers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.