Be the first user to complete this post

Add to List 
Calculate Logn base r – Java Implementation
Objective: Given a number n and r, write a program to calculate Log_{r}n
Example:
N = 32, r =2 Log_{2}32= 5 N = 64, r = 4 Log_{4}64= 3
Approach:
Without using builtIn function
 Initialize result = 0.
 Keep dividing the given number by r till number is greater than 0 and add one to the result if n is greater than equal to 1.
Java Code:
Output:
Log64 with base 4 value: 3.0
Using builtIn function
 Use Java built in function to compute.
Java Code:
Output:
Log64 with base 4 value: 3.0
Also Read: