Java Program to Find Logarithm of a Number

bookmark

import java.util.Scanner;
class Main
{
    public static void main(String args[]) 
    {
        //a number declared
        int n = 15;
        System.out.println("Logarithm of " + n + " is " + Math.log(n));
        System.out.println("Logarithm10 of " + n + " is " + Math.log10(n));
    }
}

 


Output:

Logarithm of 15 is 2.70805020110221
Logarithm10 of 15 is 1.1760912590556813