+ 1
How to compute log?
How to compute logarithmic function without using library ? This is my attempt https://code.sololearn.com/WF2v2oX0HPa9/?ref=app But it's not 100% accurate. What are the other ways?
2 ответов
+ 1
I think you should try this one, 
class Gfg1  
{ 
  
    static int Log2n(int n) 
    { 
        return (n > 1) ? 1 + Log2n(n / 2) : 0; 
    } 
      
    // Driver Code 
    public static void main(String args[]) 
    { 
        int n = 32; 
        System.out.println(Log2n(n)); 
    } 
}
0
Yash Sehgal 
For what base of log it works? And how can I change that?



